HDU-1036 Average is not Fast Enough!
Average is not Fast Enough!
http://acm.hdu.edu.cn/showproblem.php?pid=1036
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.
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.
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.
5 0:23:21 0:25:01
42 0:23:32 -:--:--
7 0:33:20 0:41:35
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!的更多相关文章
- 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 ...
- 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 ...
- 2015多校第6场 HDU 5353 Average 贪心,细节处理
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5353 题意:有n个人围城一个环,每一个人手里都有一些糖果,第i个人有ai块.现在有三种操作:第i个人给 ...
- HDU 5353—— Average——————【贪心+枚举】
Average Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total S ...
- hdu 2736 Average distance
传送门 Average distance Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- HDU 5353 Average 糖果分配(模拟,图)
题意:有n个人坐在圆桌上,每个人带着糖果若干,每次只能给旁边的人1科糖果,而且坐相邻的两个人最多只能给一次(要么你给我,要么我给你),问是否能将糖果平均分了. 思路: 明显每个人最多只能多于平均值2个 ...
- HDU - 1036
题意描述很垃圾,后来看别人代码才知道怎么回事:对(题目所给d/总时间:所有时间加起来)四舍五入并取整,然后对结果/60得到用了几分钟:对结果%60得到用了几秒. presentation error一 ...
- HDU 1036(平均速度 **)
题意是求出跑了 n 圈每圈 m km 的个人的平均速度. 控制格式,特别注意,题意是输出 -:--:-- 的该人成绩作废,但要把他其他的成绩输进去,不能直接就 break ,输出也就只有一个 - ,而 ...
- HDU 5353 Average
Problem Description There are n soda sitting around a round table. soda are numbered from 1 to n and ...
随机推荐
- Javascript访问css样式信息
DOM2级样式为style对象定义了一些属性和方法,可以通过这些方法属性来访问或者修改元素的样式信息: 1.cssText:可读写,在读的情况下以字符串形式返回元素的css代码,在写的情况下以字符串形 ...
- jquery 100%全屏自适应宽可点击左右和焦点的自动切换幻灯片特效
http://www.divcss5.com/css-texiao/texiao717.shtml http://d.divcss5.com/divcss5/down/2014062201.zip
- 图片裁切插件jCrop的使用心得(一)
之前,项目经理为了提升用户体验让我在之前图片上传功能的基础上实现图片的裁切功能,作为一个前端小白来说听了这个需求心里一紧,毕竟没有做过,于是跟项目经理商量要先做下调研.在一上午的调研中发现了jCrop ...
- React Native在虚拟运行app时,报错RCTRootView not found,怎么解决?
报错: 解决方案:
- mysql存储过程讲解
1.数据库存储过程:简单滴说,存储过程就是存储在数据库中的一个程序. 2..数据库存储过程作用: 第一:存储过程因为SQL语句已经预编绎过了,因此运行的速度比较快. 第二:存储过程可以接受参数.输出参 ...
- jenkins 重新设置 管理员密码
由于服务器瘫痪,修好之后经常不上,就把jenkins的管理密码忘掉了. 查阅了网上所有方案之后发现没有一个 能正确修改密码的,特此列出下列网上的方法 第一.设成无需密码验证的(网上有教程,不过并不能修 ...
- 【Ubuntu12.04】安装搜狗输入法
我的系统版本是Ubuntu12.04 32位 卸载Ibus输入法 sudo apt-get remove ibus 注意: 安装ibus的命令是 sudo apt-get install fcitx ...
- ARM的工作环境和工作模式
工作环境: 可以称之为“数据环境,”数据总线16位或者32位,应用于不同的情况下.16位的情况下,工作速度快,代码密度高. 工作模式: 设置程序数据所处的状态,为移植操作系统提供方便.
- 【存储器相关】RAM、SRAM、SDRAM、ROM、EPROM、EEPROM、Flash存储器区别
常见存储器概念:RAM.SRAM.SDRAM.ROM.EPROM.EEPROM.Flash存储器可以分为很多种类,其中根据掉电数据是否丢失可以分为RAM(随机存取存储器)和ROM(只读存储器),其中R ...
- Delphi XE5 android 图解为Android应用制作签名
本文摘自 http://redboy136.blog.163.com/blog/static/107188432201381872820132 要发布android应用,必须做签名的.看一下具体的操作 ...