Posted: Sat Oct 27, 2007 5:04 pm
so if input is 1 1 1 1 then triple peak is occuring at 1 which is given date so next peak will occur after 21525 days . here i changed the condititon in my code but still getting WA . plz help meIf a triple peak occurs on the given date, you should give the number of days to the next occurrence of a triple peak.
Code: Select all
#include<cstdio>
int main()
{
int a,b,c,d,sum,m,w,i=1;
while(scanf("%d%d%d%d",&a,&b,&c,&d)==4 && (a!=-1 || b!=-1 || c!=-1 || d!=-1))
{
sum=0;
a=a%23;
b=b%28;
c=c%33;
m=21252;
w=6;
sum=sum+a*w*924;
w=-9;
sum=sum+b*w*759;
w=2;
sum=sum+c*w*644;
//printf("%d\n",sum);
while(sum<=d)
sum=sum+21252;
printf("Case %d: the next triple peak occurs in %d days.\n",i++,sum-d);
}
}