Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:哪位好心人能告诉我错哪了呢?我都要疯了

Posted by A0317462 at 2004-03-21 15:26:17 on Problem 1006
In Reply To:Re:哪位好心人能告诉我错哪了呢?我都要疯了 Posted by:90303115 at 2003-11-16 19:31:02
#include <iostream.h>
#include <stdlib.h>
const int P=23;
const int E=28;
const int I=33;

void main()
{
	int p=0,e=0,i=0,d=0,jump,count,temp,Psig,Isig,Esig;
	
	count=1;
	while(1)
	{	
		jump=1;
		Psig=0;
		Isig=0;
		Esig=0;

		cin>>p>>e>>i>>d;
		if(p>365||e>365||i>365||d>365||p<0||e<0||i<0||d<0)
			exit(0);

		temp=d;

		while(jump!=P*I*E)
		{
			d=d+jump;
			if((d-p)%P==0&&Psig==0)
			{
				jump=jump*P;
				Psig=1;
			}
			if((d-e)%E==0&&Esig==0)
			{
				jump=jump*E;
				Esig=1;
			}
			if((d-i)%I==0&&Isig==0)
			{
				jump=jump*I;
				Isig=1;
			}
		}	
		cout<<"Case "<<count<<": the next triple peak occurs in "<<d-temp<<" days."<<endl;	
		count++;
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator