Problem Descripton
Two planets named Haha and Xixi in the universe and they were created with the universe beginning.
There is 73 days in Xixi a year and 137 days in Haha a year.
Now you know the days N after Big Bang, you need to answer whether it is the first day in a year about the two planets.
There is 73 days in Xixi a year and 137 days in Haha a year.
Now you know the days N after Big Bang, you need to answer whether it is the first day in a year about the two planets.
Input
There are several test cases(about 5 huge test cases).
For each test, we have a line with an only integer N(0≤N), the length of N is up to 10000000.
For each test, we have a line with an only integer N(0≤N), the length of N is up to 10000000.
Output
For the i-th test case, output Case #i: , then output "YES" or "NO" for the answer.
Sample Input 10001 0 333 Sample Output Case #1: YES Case #2: YES Case #3: NO
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5832
***********************************************************
题意:嘻嘻和哈哈两个星球分别以73和137为一年的周期,给你天数,判断是否是两个星球的新一年第一天。
分析:周期嘛:10001就是73和137的最小公倍数。然后输入的是字符串,注意给的范围是字符串的长度不是数的大小,所以用到大数求余,仅此而已。
AC代码:
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <cmath> 6 #include <stack> 7 #include <map> 8 #include <vector> 9 using namespace std; 10 11 #define N 12000000 12 #define INF 0x3f3f3f3f 13 14 char s[N]; 15 16 int main() 17 { 18 int k=0,len,x,d,i; 19 20 while(scanf("%s", s) != EOF) 21 { 22 k++; 23 len = strlen(s); 24 25 x=10001; 26 d=0; 27 28 for(i=0;i<len;i++) 29 d=(d*10+(s[i]-'0')%x)%x; 30 31 if(d==0) 32 printf("Case #%d: YES ",k); 33 else 34 printf("Case #%d: NO ",k); 35 } 36 return 0; 37 }