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

各位抽空给看看吧,杂老是wa,花不了多少时间的,真的谢谢了,再次谢谢了

Posted by tencent at 2005-03-06 20:41:02 on Problem 1006
#include<iostream.h>
int max(int a,int b,int ,int d);

void main ()
{
	const int value=365+23*28*33;
	int a,b,c,i,j=1,days,nowdays;
	while(cin>>a>>b>>c>>nowdays,!(a==-1&&b==-1&&c==-1&&nowdays==-1))
		for(i=max(a,b,c,nowdays)+1;i<=value;i++)
			if((i-a)%23==0&&(i-b)%28==0&&(i-c)%33==0)
			{
				days=i-nowdays;
				cout<<"Case "<<j<<": the next triple peak occurs in "<<days<<" days."<<endl;
				j++; break;
			}
}

int max(int a,int b,int c,int d)
{
	if(a>=b&&a>=c&&a>=d)  return a;
	if(b>=a&&b>=c&&b>=d)  return b;
	if(c>=a&&c>=b&&c>=d)  return c;
	else return d;
}

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