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

不要每次加1,找到23的倍数后每次加23,找到28的倍数后每次加23*28

Posted by ava at 2003-11-17 17:02:51 on Problem 1006
In Reply To:怎样才能令它不超时呢?救命啊 Posted by:90303109 at 2003-11-16 16:55:18
> #include<math.h>
> #include<stdio.h>
> void main(){
> 	int p,e,i,d,n,k,m,date,endp;
> 	n=1;
> 	do{	scanf("%d %d %d %d",&p,&e,&i,&d);
> 		endp=0,m=0,date=d+1;
> 		while(endp!=1&&p!=-1){
> 			if((date-p)%23==0&&(date-e)%28==0&&(date-i)%33==0){
> 				printf("Case %d: the next triple peak occurs in %d days.\n",n,date-d);
> 				endp=1;
> 				n=n+1;
> 			}
> 			date=date+1;
> 		}
> 	}while(p!=-1&&e!=-1&&i!=-1&&d!=-1);
> }

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