转载请注明出处:http://exp-blog.com/2018/06/24/pid-1054/
1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 int main() 5 { 6 int p,e,i,d,n=0; 7 while (scanf("%d %d %d %d",&p,&e,&i,&d)) 8 { 9 if (p==-1&&e==-1&&i==-1&&d==-1)//记得出口!!! 10 { 11 break; 12 } 13 n++; 14 p=p%23;//找第一个高峰期 15 e=e%28; 16 i=i%33; 17 int j; 18 for (j=i;;j+=33) 19 { 20 if (j%23==p&&j%28==e&&i%33==i&&j>d) 21 { 22 printf("Case %d: the next triple peak occurs in %d days. ",n,j-d); 23 break; 24 } 25 } 26 } 27 28 return 0; 29 }