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

Re:O(1)算法(中国剩余定理)

Posted by zsasuke at 2008-06-17 20:38:49 on Problem 1006
In Reply To:O(1)算法(中国剩余定理) Posted by:FOR_RITZ at 2006-11-19 12:02:34
#include<iostream>
using namespace std;
int main()
{
	int i,p,e,d,w,ci=1;
	cin>>p>>e>>i>>d;
	
		while(p!=-1)
		{
			p%=23;
			e%=28;
			i%=33;
			w=(5544*p+14421*e+1288*i)%21252;
			if(w<=d)
				w+=(21252-d);
			else
				w-=d;
			printf("Case %d: the next triple peak occurs in %d days.\n",ci++,w);

cin>>p>>e>>i>>d;
	
	}
		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