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

应该是那个getchar()有问题,N后面可能有空格再加回车

Posted by windbells at 2004-07-22 10:39:40 on Problem 1304
In Reply To:没感觉有什么啊,怎么会超时呢??,好心人看一下 Posted by:dexter at 2004-04-29 23:25:02
> #include<stdio.h>
> #include<string.h>
> #include<stdlib.h>
> char tag[sizeof("ENDOFINPUT")];
> struct bus
> {
> 	int m;
> 	int routs[10];
> 	int close;
> }buses[20];
> int art;//arrive time
> int N;
> void count()
> {
> 	int sum,i,j;
> 	int min;
> 	min=100000;//so big
> 	for(i=0;i<N;i++)
> 	{
> 		sum=0;
> 		j=0;
> 		while(1)
> 		{
> 			if(sum>=art)
> 			{
> 				buses[i].close=sum;
> 				if(sum<min)
> 					min=sum;
> 				break;
> 			}
> 			if(j==buses[i].m)
> 				j=0;
> 			sum+=buses[i].routs[j];
> 			j++;
> 		}
> 	}
> 	printf("%d\n",min-art);
> }
> int main()
> {
> 	int n,i,len,j;
> 	char str[50];
> 	while(1)
> 	{
> 		scanf("%s",tag);
> 		if(!strcmp(tag,"ENDOFINPUT"))
> 			break;
> 		scanf("%d",&N);
> 		getchar();                 ------while((getchar())!=10);
> 		for(i=0;i<N;i++)
> 		{
> 			n=0;
> 			gets(str);
> 			len=strlen(str);
> 			for(j=0;str[j];j++)
> 				if(str[j]==' ')
> 					str[j]=0;
> 			for(j=0;j<len;)
> 			{
> 				buses[i].routs[n]=atoi(&str[j]);
> 				n++;
> 				j=j+strlen(&str[j])+1;
> 			}
> 			buses[i].m=n;
> 		}
> 		scanf("%d",&art);
> 		count();
> 		scanf("%s",tag);
> 	}
> }
> 

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