Average is not Fast Enough!

http://acm.hdu.edu.cn/showproblem.php?pid=1036

Problem Description
A relay is a race for two or more teams of runners. Each member of a team runs one section of the race. Your task is to help to evaluate the results of a relay race.

You have to process several teams.
For each team you are given a list with the running times for every section of
the race. You are to compute the average time per kilometer over the whole
distance. That's easy, isn't it?
So if you like the fun and challenge
competing 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 is
over.

 
Input
The first line of the input specifies the number of
sections n followed by the total distance of the relay d in kilometers. You may
safely assume that 1 <= n <= 20 and 0.0 < d < 200.0. Every following
line gives information about one team: the team number t (an integer,
right-justified in a field of width 3) is followed by the n results for each
section, separated by a single space. These running times are given in the
format "h:mm:ss" with integer numbers for the hours, minutes and seconds,
respectively. In the special case of a runner being disqualified, the running
time will be denoted by "-:--:--". Finally, the data on every line is terminated
by a newline character. Input is terminated by EOF.
 
Output
For each team output exactly one line giving the team's
number t right aligned in a field of width 3, and the average time for this team
rounded to whole seconds in the format "m:ss". If at 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
5 0:23:21 0:25:01
42 0:23:32 -:--:--
7 0:33:20 0:41:35
 
Sample Output
5: 3:52 min/km
42: -
7: 6:00 min/km
 
#include<stdio.h>
int main()
{
int n;
double d;
int num;
char h,m1,m2,s1,s2;
scanf("%d",&n);
scanf("%lf",&d);
while(scanf("%d",&num)!=EOF)
{ printf("%3d: ",num);
bool flag=true;
int sumtime=;
for(int i=;i<n;i++)
{getchar();
scanf("%c:%c%c:%c%c",&h,&m1,&m2,&s1,&s2);
if(h=='-') flag=false;
if(flag==false)continue;
sumtime+=(h-'')*+((m1-'')*+(m2-''))*+(s1-'')*+(s2-'');
}
if(flag==false)printf("-\n");
else
{
double t1=sumtime/d;
int t2=(int)(t1+0.5);
printf("%d:%02d min/km\n",t2/,t2%); }
}
return ;
}

HDU-1036 Average is not Fast Enough!的更多相关文章

  1. hdu 1036 (I/O routines, fgets, sscanf, %02d, rounding, atoi, strtol) 分类: hdoj 2015-06-16 19:37 32人阅读 评论(0) 收藏

    thanks to http://stackoverflow.com/questions/2144459/using-scanf-to-accept-user-input and http://sta ...

  2. HDU1036 Average is not Fast Enough!

    Problem Description A relay is a race for two or more teams of runners. Each member of a team runs o ...

  3. 2015多校第6场 HDU 5353 Average 贪心,细节处理

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5353 题意:有n个人围城一个环,每一个人手里都有一些糖果,第i个人有ai块.现在有三种操作:第i个人给 ...

  4. HDU 5353—— Average——————【贪心+枚举】

    Average Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total S ...

  5. hdu 2736 Average distance

    传送门 Average distance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  6. HDU 5353 Average 糖果分配(模拟,图)

    题意:有n个人坐在圆桌上,每个人带着糖果若干,每次只能给旁边的人1科糖果,而且坐相邻的两个人最多只能给一次(要么你给我,要么我给你),问是否能将糖果平均分了. 思路: 明显每个人最多只能多于平均值2个 ...

  7. HDU - 1036

    题意描述很垃圾,后来看别人代码才知道怎么回事:对(题目所给d/总时间:所有时间加起来)四舍五入并取整,然后对结果/60得到用了几分钟:对结果%60得到用了几秒. presentation error一 ...

  8. HDU 1036(平均速度 **)

    题意是求出跑了 n 圈每圈 m km 的个人的平均速度. 控制格式,特别注意,题意是输出 -:--:-- 的该人成绩作废,但要把他其他的成绩输进去,不能直接就 break ,输出也就只有一个 - ,而 ...

  9. HDU 5353 Average

    Problem Description There are n soda sitting around a round table. soda are numbered from 1 to n and ...

随机推荐

  1. JavaScript 继承的几种模式

    /** * Created by 2016 on 2016/6/5. */ //1.原型链继承 //把子类的原型,定义为超类的实例 通过原型来访问超类的方法和属性 function Person(){ ...

  2. Html5页面返回机制解决方案

    需要处理的返回场景: 1.正常的a->b->c 2.页面上的按钮触发需要登陆 3.页面跳转需要登陆 4.页面上的可修改的部分(如选择地址,地址页面本身也是可以增删改查的) 整体的原则是原路 ...

  3. Linux下GPIO驱动(四) ----gpio_request();gpio_free();

    //gpio_request申请gpio口 int gpio_request(unsigned gpio, const char *label) { struct gpio_desc *desc; s ...

  4. 【WEB-INF】WEB-INF是Java的WEB应用的安全目录

    WEB-INF下的东西是禁止直接访问的.如果这个页面是你的,要想让人访问最好不要放在这个目录下.如果一定放在那里.你可以使用:request.getRequestDispatcher("/W ...

  5. JAVA自学之-----FileInputStream类

    1, FileInputStream类函数创建: package coreJava; import java.io.FileInputStream; import java.io.IOExceptio ...

  6. BZOJ 2442: [Usaco2011 Open]修剪草坪

    Description 在一年前赢得了小镇的最佳草坪比赛后,FJ变得很懒,再也没有修剪过草坪.现在,新一轮的最佳草坪比赛又开始了,FJ希望能够再次夺冠.然而,FJ的草坪非常脏乱,因此,FJ只能够让他的 ...

  7. WebKit Web Inspector增加覆盖率分析和类型推断功能

    WebKit中的Web Inspector(Web检查器)主要用于查看页面源代码.实时DOM层次结构.脚本调试.数据收集等,日前增加了两个十分有用的新功能:覆盖率分析和类型推断.覆盖率分析工具能够可视 ...

  8. zoj 3761

    很简单但很虐心的一道题: 我感觉自己的算法没错,但是老是过不了:= = 但是还是把代码贴出来: 我的方法,用并查集的方式做一课树,然后对树进行遍历: 有多少棵树就有多少个点剩余: #include&l ...

  9. Access forbidden! XAMPP虚拟主机的问题

    XAMPP Control Panel v3.2.1添加虚拟主机出现 Access forbidden! You don't have permission to access the request ...

  10. 过生日,也要学学哈,这次是SHELL的GETOPTS

    今天是WEBSOCKET,, 先完成一个SHELL的GETOPS,周一就用得着. #!/bin/bash echo "usage: ./$0 -t (prism|opscripts)&quo ...