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 szc529 at 2011-11-24 11:28:56 on Problem 1006
用中国剩余定理AC了,但是原来写的这个就总是WA,贴代码,求数据!!
大牛,赐教
#include<stdio.h>
int p,e,i,d;
int Can(int a)
{
	if(!a)
		return 0;
	if((a-e)%28==0)
	{
		if((a-p)%23==0)
		{
			return 1;
		}
	}
	return 0;
}
int main()
{

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