题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=5832
Problem Description
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
Hint:
题意:
就是给一个数n,让你看看是不是能够被73,137整除。
题解:
其实就是一道水题,十分水的题目,但是比赛的时候还是wa了,主要注意两点,一点是这个n是比较大的,所以要用的大数的除法,还有一点就是不能直接除以10001,自己就是因为这个一直在超时。
代码:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 10000000+10 #define met(a,b) memset(a,b,sizeof(a)) char s[maxn]; int main() { int k=1; while(scanf("%s",s)!=EOF) { printf("Case #%d: ",k++); int l=strlen(s); int ans1=0,ans2=0; for(int i=0;i<l;i++) { ans1=(ans1*10+s[i]-'0')%73; ans2=(ans2*10+s[i]-'0')%137; } if(ans1==0&&ans2==0) printf("YES "); else printf("NO "); } }