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 08060029 at 2009-07-17 09:22:09 on Problem 1006
用中国剩余定理固然可以做出来,但请问我这样做怎就wa了呢?麻烦看一下


#include<stdio.h>

int main()
{
	int a1,a2,a3,d,day,n,i=0;
	
	
	while(scanf("%d%d%d%d",&a1,&a2,&a3,&d)!=EOF)
	{
		if(a1==a2&&a2==a3&&a3==d&&a1==-1)
			return 0;
		else 
		{
			i++;
			n=1;
			while(1)
			{
				day=n*23+a1;
				if((day-a2)%28==0&&(day-a3)%33==0&&day-d>0)
					break;
				else	n++;
			}
			printf("Case %d: the next triple peak occurs in %d days.\n",i,day-d);
		}
	}
	return 0;
}
    

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