| ||||||||||
| 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 | |||||||||
没有使用中国剩余定理,挨个试,怎么是Wrong Answer了呢?代码如下,试了几个用例,都是正确的呀。
#include <stdio.h>
int main()
{
int p,e,i,d;
int a,b,c;
int date;
int case_num=1;
while(1)
{
scanf("%d %d %d %d",&p,&e,&i,&d);
if(p==-1 && e==-1 && i==-1 && d==-1)
break;
a=p%23;
b=e%28;
c=i%33;
date=d+1;
while(date<=21252)
{
if( (date-a)%23==0 && (date-b)%28==0 && (date-c)%33==0 )
break;
date++;
}
printf("Case %d: the next triple peak occurs in %d days.\n",case_num,date-d);
case_num++;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator