(HDU)1393 -- Weird Clock (奇怪的时钟)

题目链接:http://vjudge.net/problem/HDU-1393

这题要判断是否有解,如果有解的话60步内是一定可以完成的。

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <iostream>
 5 #include <algorithm>
 6 #include <string>
 7 #include <cstdlib>
 8 
 9 using namespace std;
10 
11 int main()
12 {
13     int t,d,ans;
14     while(~scanf("%d %d",&t,&d)&&(t||d))
15     {
16         int flag=1;
17         for(ans=0;;ans++)
18         {
19 
20             if(t%60==0) break;
21             t*=(d+1);
22             t%=60;
23             if(ans==61)
24             {
25                 flag=0;
26                 break;
27             }
28         }
29         if (flag) printf("%d
",ans);
30         else printf("Impossible
");
31     }
32     return 0;
33 }
原文地址:https://www.cnblogs.com/ACDoge/p/6137958.html