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:不用中国剩余定理,不用暴力枚举,16ms过的一个代码。

Posted by amdunkszy at 2011-06-23 19:19:46 on Problem 1006
In Reply To:不用中国剩余定理,不用暴力枚举,16ms过的一个代码。 Posted by:20092462 at 2010-01-31 22:42:14
> #include<stdio.h>
> int main()
> {
> 	int p,e,i,k,d,t,r,x;
> 
> 	x=0;
> 	while(scanf("%d %d %d %d",&p,&e,&i,&d) && p!=-1)
> 	{
> 		x++;
> 		p=p%23; e=e%28; i=i%33;
> 		t=e-p;
> 		k=0;
> 		while(t%23!=0)
> 		{
> 			k++;
> 			t+=5;
> 		}
> 
> 		t=e+k*28;
> 
> 		r=t-i;
> 		k=0;
> 		while(r%33!=0)
> 		{
> 			k++;
> 			r+=611;
> 		}
> 
> 		r=t+k*644;
> 
> 		if(r>d) r=r-d; else r=r+21252-d;
> 			
> 		printf("Case %d: the next triple peak occurs in %d days.\n",x,r);
> 	}
> 
> 	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