| ||||||||||
| 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 | |||||||||
g++AC,c++超时,用的是一一列举,能有更好的办法吗?#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
int p,e,i,d,j,k=1;
cin>>p>>e>>i>>d;
while(p!=-1)
{
p=p%23;e=e%28;i=i%33;
for(j=d+1;;j++)if((j-p)%23==0&&(j-e)%28==0&&(j-i)%33==0) break;
cout<<"Case "<<k<<": the next triple peak occurs in "<<j-d<<" days."<<endl;
k++;
cin>>p>>e>>i>>d;
}
//system("PAUSE");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator