| ||||||||||
| 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 | |||||||||
看看我这答案正确,为什么总是RUN time Eorror!我利用的是中国余数定理求的,应该很快啊!但就通不过啊
#include<iostream.h>
const int E=23,P=28,I=33,M=21252;
int main()
{
int i,j;
int e,p,d;
int num[50];
cin>>e>>p>>i>>d;
j=0;
while(e!=-1||p!=-1||d!=-1||i!=-1)
{
num[j]=((e%E)*5544+(p%P)*(-6831)+(i%I)*1288);//中国余数定理5544=28*33*6,-6831=-9*759
if(num[j]<=0)
num[j]+=((-num[j])/M+1)*M;
num[j]-=d;
j++;
cin>>e>>p>>i>>d;
}
for(i=0;i<j;i++)
{
cout<<"Case "<<i+1<<": the next triple peak occurs in "<<num[i]<<" days."<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator