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

没有使用中国剩余定理,挨个试,怎么是Wrong Answer了呢?

Posted by yulubupt at 2014-04-23 21:04:30 on Problem 1006
代码如下,试了几个用例,都是正确的呀。

#include <stdio.h>

int main()
{
	int p,e,i,d;
    int a,b,c;
	int date;
	int case_num=1;
	while(1)
	{
		scanf("%d %d %d %d",&p,&e,&i,&d);
		if(p==-1 && e==-1 && i==-1 && d==-1)
		    break;
        
        a=p%23;
        b=e%28;
        c=i%33;
        date=d+1;
        while(date<=21252)
        {
        	if( (date-a)%23==0 && (date-b)%28==0 && (date-c)%33==0 )
        	    break;
    	    date++;
        }
        printf("Case %d: the next triple peak occurs in %d days.\n",case_num,date-d);
        case_num++;
	}
	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