http://poj.grids.cn/problem?id=2977
题目是要求三个生理周期高峰出现在同一天的时间,即三个数的最小公倍数。
1 #include<stdio.h>
2 int p,e,j,d;
3 int main()
4 {
5 int k = 1;
6 int i;
7 while(scanf("%d%d%d%d",&p,&e,&j,&d) != EOF && p != -1){
8 for(i = d+1;i < 21252;++i)
9 if((i-p)%23 == 0)break;
10 for(;i < 21252;i+=23)
11 if((i-e)%28 == 0)break;
12 for(;i < 21252;i+=23*28)
13 if((i-j)%33 == 0)break;
14 printf("Case %d: the next triple peak occurs in %d days.\n",k++,i-d);
15 }
16 return 0;
17 }
18