Average is not Fast Enough 2010.3.6

来源:互联网 发布:波波维奇 知乎 编辑:程序博客网 时间:2024/06/07 16:03

Average is not Fast Enough 2010.3.6

wa因:60*60=3600,我写成了360

 

能让电脑算的,自己坚决不算,防止出错

 

 

Average is not Fast Enough!

 

Time Limit:1000MS  Memory Limit:65536K

Total Submit:31 Accepted:11

 

Description

 

A relay is a race for two or more teams ofrunners. Each member of a team runs one section of the race. Your task is tohelp to evaluate the results of a relay race. You have to process severalteams. For each team you are given a list with the running times for everysection of the race. You are to compute the average time per kilometer over thewhole distance. That's easy, isn't it?

So if you like the fun and challengecompeting at this contest, perhaps you like a relay race, too. Students from Ulm participated e.g. at the "SOLA" relay in Zurich, Switzerland.For more information visit http://www.sola.asvz.ethz.ch/ after the contest isover.

 

Input

 

The first line of the input specifies thenumber of sections n followed by the total distance of the relay d inkilometers. You may safely assume that 1<=n<=20 and 0.0

 

Output

 

For each team output exactly one linegiving the team's number t right aligned in a field of width 3, and the averagetime for this team rounded to whole seconds in the format "m:ss". Ifat least one of the team's runners has been disqualified, output "-" instead.Adhere to the sample output for the exact format of presentation.

 

Sample Input

 

 

2 12.5

  50:23:21 0:25:01

 420:23:32 -:--:--

  70:33:20 0:41:35

 

Sample Output

 

 

  5:3:52 min/km

 42:-

  7:6:00 min/km

 

Source

 

ULM 2001

#include <stdio.h>#include <string.h>void main(){char mid[100],s[200];int a,b,c,aa,bb,cc,flag,name,n,i,f,h,w,ts;double d,r,l;scanf("%d %lf",&n,&d);gets(mid);while (scanf("%d",&name)!=EOF){        printf("%3d: ",name);    a=0;b=0;c=0;flag=0;for(i=1;i<=n;i++){getchar();scanf("%s",s);if (s[0]!='-'){sscanf(s,"%d:%d:%d",&aa,&bb,&cc);a+=aa;b+=bb;c+=cc;}else {flag=1;}}if (flag==1) printf("-\n");else{ts=a*3600+b*60+c;r=(double)ts/d;l=r*10;w=(int)l%10;if(w>=5) r++;f=(int)(r/60);h=(int)r-f*60;printf("%d:%02d min/km\n",f,h);}}}



0 0
原创粉丝点击