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

哪里错了啊,答案就是不对啊,谁来看看吧……

Posted by cpp050300448135 at 2005-03-13 04:21:56 on Problem 1006
#include<iostream.h>

int same(int a, int b, int c,int d)
{
	int aa=0,bb=0,cc=0;
	for(int i=1;aa<21252;i++)
	{
		aa=a+i*23;
		for(int j=1;bb<21252;j++)
		{	
			bb=b+j*28;
		    for(int k=1;cc<21252;k++)
			{
			 cc=c+k*33;
             if(aa==bb&&bb==cc) return(aa-d);
			}
		}
	}
}

void main()
{
	int t=0,m=1,a,b,c,d;
	for(;;)
	{
		cin>>a>>b>>c>>d;
		if(a==(-1) && b==(-1) && c==(-1) && d==(-1)) break;
		cout<<"Case"<<m<<": the next triple peak occurs in "<<same(a,b,c,d)<<" days."<<endl;
        m++;
	}

}

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