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:为什么下面这段程序在自己的环境里没问题,叫了就wronganswer呢?

Posted by ljl08 at 2007-07-22 12:26:12 on Problem 1006
In Reply To:为什么下面这段程序在自己的环境里没问题,叫了就wronganswer呢? Posted by:ljl08 at 2007-07-22 12:25:31
> #include <stdio.h>
> int input(int  &p,int &e,int &i,int &d){
> 	scanf("%d%d%d%d",&p,&e,&i,&d);
> 	if(p==-1&&e==-1&&i==-1&&d==-1)return 0;
> 	else return 1;
> }
> int search(int i,int e,int n,int cycle){
> 	int high,low,mid;
> 	high=n;low=1;
> 	while(low<=high){
> 		mid=(high+low)/2;
>         if(i==e+mid*cycle)return mid;
> 		else if(i<e+mid*cycle)high=mid-1;
> 		else low=mid+1;
> 	}
> 	return 0;
> }
> void main(){
> 	int p,e,i,d;
> 	int n,r[30];
> 	for(int k=0;k<30;k++){
> 		r[k]=0;
> 	}
>     k=0;
> 	int time,day;
> 	while(input(p,e,i,d)){
> 		for(n=1;n<=644;n++){
>  		if(search(i+n*33,e,759,28)){
> 				time=search(i+n*33,p,924,23);
> 				if (time!=0){
> 					r[k]=p+time*23-d;
> 					k++;
> 				}
> 			}
> 		}
> 	}
> 	n=0;
> 	while(n<k){
> 		day=r[n];
> 		printf("Case %d: the next triple peak occurs in %d days.\n",n+1,day);
> 		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