题目链接:http://poj.org/problem?id=1006
完成poj 1006,代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #include <iostream> using namespace std; int main() { int p,e,i,d,q; long int n,m=1; while(cin>>p>>e>>i>>d) { n=1; if(p!=-1||e!=-1||i!=-1||d!=-1) { while(!((n-p)%23==0&&(n-e)%28==0&&(n-i)%33==0)) n++; q=(n-d)%21252; if(q<=0) q+=21252; cout<<"Case "<<m<<": the next triple peak occurs in "<<q<<" days."<<endl; m++; } else break; } }
|