756 - Biorhythms

All about problems in Volume 7. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

mukeshtiwari
Learning poster
Posts: 63
Joined: Tue Mar 07, 2006 6:51 pm
Location: india

Post by mukeshtiwari »

If a triple peak occurs on the given date, you should give the number of days to the next occurrence of a triple peak.
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 me

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);
			}
		}
mukeshtiwari
Learning poster
Posts: 63
Joined: Tue Mar 07, 2006 6:51 pm
Location: india

Post by mukeshtiwari »

If a triple peak occurs on the given date, you should give the number of days to the next occurrence of a triple peak.
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 me

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);
			}
		}
mukeshtiwari
Learning poster
Posts: 63
Joined: Tue Mar 07, 2006 6:51 pm
Location: india

Post by mukeshtiwari »

Thnkx everybody . accepted
Post Reply

Return to “Volume 7 (700-799)”