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 JuniorStudent at 2008-02-19 01:01:04 on Problem 1006
用中国剩余定理求days时这段代码是WA的 (M1等定义为全局了)

int Biorhythms(int p,int e,int i,int d)
{
	int y1,y2,y3,day;
	y1=y2=y3=1;
	while((y1*M1-1)%a!=0)
		y1++;
	while((y2*M2-1)%b!=0)
		y2++;
	while((y3*M3-1)%c!=0)
		y3++;
	day = (p*y1*M1 + e*y2*M2 + i*y3*M3)%21252;
	if(day==0) day = 21252;
	return (day - d + 21252)%21252;
}

但是稍稍改动一下后却是AC

int Biorhythms(int p,int e,int i,int d)
{
	int y1,y2,y3,day;
	y1=y2=y3=1;
	while((y1*M1-1)%a!=0)
		y1++;
	while((y2*M2-1)%b!=0)
		y2++;
	while((y3*M3-1)%c!=0)
		y3++;
	day = (p*y1*M1 + e*y2*M2 + i*y3*M3 -d + 21252)%21252;
	if(day==0) day = 21252;
	return day;
}

有谁能解释一下吗,thanks in advance。

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