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 |
为什么超时呢?#include<iostream.h> #include<math.h> void main() { int p=0,e=0,i=0,day=0; int n,sum[100]; for(int j=1;p != -1 && e != -1 && i != -1 && day != -1;j++) { cin>>p>>e>>i>>day;if (p==-1) break; for(int d=i;d<=21252;d+=33) { if(fmod(d-e,28)!=0) continue; else if(fmod(d-p,23)!=0) continue; else { if (d-day>0) { n=j;sum[j]=d-day;break; } } } } for(j=1;j<=n;j++) cout<<"Case "<<j<<": the next triple peak occurs in "<<sum[j]<<" days."<<endl; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator