Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 67911 Accepted: 19964

本题虽然非常简单,但是陷阱却很难发现

下面给几组例子:(据说只要能过这几组例子就能A过)

 

0 4 5 0                368
2 2 2 2                21252
123 128 133 1     99
123 128 133 100 21252
0 1 2 1               16996
1 0 2 1               8119
1 2 0 1               13133
1 2 3 0               16998
117 58 2 27        21227
尤其最后一组例子,很容易被忽略

代码:

 

1 #include<stdio.h>
2  int main()
3 {
4 int p,e,i,j,d,count=0,s;
5 while(scanf("%d%d%d%d",&p,&e,&i,&d)!=EOF)
6 {
7 count++;
8 if(p==-1&&e==-1&&i==-1&&d==-1)
9 break;
10 s=21252+d;
11 for(j=1;j<=s;j++)
12 {
13 if((j-p)%23==0 && (j-e)%28==0 && (j-i)%33==0)
14 {
15 if((j-d)<=0)
16 continue;
17 else
18 break;
19 }
20 }
21 if(j>s)
22 printf("Case %d: the next triple peak occurs in 21252 days.\n",count);
23 else
24 printf("Case %d: the next triple peak occurs in %d days.\n",count,j-d);
25 }
26 return 0;
27 }
28