Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:哪位好心人能告诉我错哪了呢?我都要疯了In Reply To:Re:哪位好心人能告诉我错哪了呢?我都要疯了 Posted by:90303115 at 2003-11-16 19:31:02 #include <iostream.h> #include <stdlib.h> const int P=23; const int E=28; const int I=33; void main() { int p=0,e=0,i=0,d=0,jump,count,temp,Psig,Isig,Esig; count=1; while(1) { jump=1; Psig=0; Isig=0; Esig=0; cin>>p>>e>>i>>d; if(p>365||e>365||i>365||d>365||p<0||e<0||i<0||d<0) exit(0); temp=d; while(jump!=P*I*E) { d=d+jump; if((d-p)%P==0&&Psig==0) { jump=jump*P; Psig=1; } if((d-e)%E==0&&Esig==0) { jump=jump*E; Esig=1; } if((d-i)%I==0&&Isig==0) { jump=jump*I; Isig=1; } } cout<<"Case "<<count<<": the next triple peak occurs in "<<d-temp<<" days."<<endl; count++; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator