Average is not Fast Enough 2010.3.6

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值