Title Address: http://acm.hdu.edu.cn/showproblem.php?pid=5832
The
topic Two planets, one year 137 days, one year 73 days, give a day to ask is not at the same time is two planets in the first days. 0 represents the first day.
Thinking of solving problems
Because 137 and 73 are prime numbers, so the least common multiple is 10001, the problem is converted to a high-precision number of 10001 to take the remainder is equal to 0.
About high-precision redundancy. For example, 123 to 12, actually equals ((1%12*10+2)%12*10+3)%12=3, which is actually the process of simulating a division.
Code
#include <cstring>
#include <cstdio>
using namespace std;
#define MAXN 10005000
int A[MAXN];
int B[MAXN];
int Len;
Char STR[MAXN];
int main ()
{
int i=1;
while (scanf ("%s", str) ==1)
{
int tomod = 10001;
int ans = 0;
for (int j = 0; str[j]; j + +)
ans = (ans * + (str[j]-' 0 '))% Tomod;
if (ans)
printf ("Case #%d:no\n", i++);
else
printf ("Case #%d:yes\n", i++);
}
return 0;
}