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 WAKU at 2006-07-22 13:11:16 on Problem 1006
注意,有可能得负值,这时结果要加上21252

刚AC,粘一下我的代码,希望对大家有帮助

#include <iostream>
using namespace std;

void main()
{
	int p, e, i, d;
	int a1 = 5544, a2 = 14421, a3 = 1288;//这三个常数可根据同余定理求得
	int j = 1;
	int n;

	while (true)
	{
		cin>>p>>e>>i>>d;
		if (-1 == p) break;
		p %= 23; e %= 28; i %= 33;
		n = (a1*p+a2*e+a3*i) % 21252;
		cout<<"Case "<<j++	<<": the next triple peak occurs in "
			<< (n - d>0?n-d:21252 + n - d)
			<<" days.\n";
	}
}

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