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 wuyadong at 2011-04-10 00:45:35
//剩余定理
#include <iostream>

using namespace std;

int main(void)
{
	int p,e,i,d;
	bool found = false;
	int m;
	m = 1;

	while(cin>>p>>e>>i>>d && p != -1)
	{

		int j = 1;
		int day;
		while(true)
		{
			day = 23 * j + p;
			if((day - e)%28 == 0)
			{
				int gridpe = 23 * 28;

				while(true)
				{
					if((day - i)%33 == 0)
					{
						cout<<"Case "<<m<<": the next triple peak occurs in "<<(day - d > 21252 ? day-d - 21252:day - d)<<" days."<<endl;
						found = true;
						break;
					}
					day += gridpe;
				}

			}

			if(found == true)
			{
				found = false;
				break;
			}
			j++;
		}
		m ++;

	}
	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