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

郁闷得很!为什么是WA呢?如果算出m>=60,怎么处理呢?

Posted by hubo430 at 2006-07-18 19:47:35 on Problem 2565
#include<stdio.h>
#include<string.h>
int main()
{
	int n,h,mm,ss,i,t;
	double d,time;
	char s[100000];
	while(gets(s))
	{
		for(i=0;s[i];i++) if(s[i]==':') break;
		if(s[i]=='\0') sscanf(s,"%d%lf",&n,&d);
		else
		{
			sscanf(s,"%d",&t);
			for(i=0;s[i];i++) if(s[i]=='-') break;
			if(s[i]){printf("%3d: -\n",t);continue;}
			time=0;			
			printf("%3d: ",t);
			for(i=0;i<n;i++)
			{
				sscanf(s+4+i*7,"%d:%d:%d",&h,&mm,&ss);
				time+=h*3600+mm*60+ss;
			}
			time/=d;
			time=(int)(time+0.5);
			mm=(int)(time/60);ss=time-mm*60;
			printf("%d:%02d min/km\n",mm,ss);
		}
	}
	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