thanks to http://stackoverflow.com/questions/2144459/using-scanf-to-accept-user-input and http://stackoverflow.com/questions/456303/how-to-validate-input-using-scanf for the i/o part.

thanks to http://www.haodaima.net/art/137347 for the rounding part. s=s/nkilo+0.5; //s=round(s/nkilo);

check return value of scanf,

std::fgets, http://en.cppreference.com/w/cpp/io/c/fgets

std::atoi, std::atol, std::atoll,

std::strtof, std::strtod, std::strtold,

std::strtol, std::strtoll,

std::strtok, http://en.cppreference.com/w/cpp/string/byte/strtok

std::round, std::lround, std::llround, http://en.cppreference.com/w/cpp/numeric/math/round

#include <cstdio>
#include <cmath>
#include <algorithm> #define MAXLEN 200
#define STEP 8
char buffer[MAXLEN]; int main() {
//freopen("input.txt","r",stdin);
int nsect, team, h,m,s, ht,mt,st, i, disqualified;
char *p;
double nkilo;
scanf("%d%lf",&nsect,&nkilo);
while(scanf("%d",&team)==1) {
h=m=s=0; disqualified=0;
p=buffer;
fgets(buffer,MAXLEN,stdin);
for(i=0;i<nsect;++i) {
if(sscanf(p,"%d:%d:%d",&ht,&mt,&st)!=3) { disqualified=1; break; }
h+=ht; m+=mt; s+=st; p+=STEP;
}
if(disqualified) { printf("%3d: -\n",team); continue; }
s+=(m*60+h*3600);
s=s/nkilo+0.5; //s=round(s/nkilo);
m=s/60; s=s%60;
printf("%3d: %d:%02d min/km\n",team,m,s);
}
return 0;
}

as the problem title of hdu 1036 ( Average is not Fast Enough! )

suggest, Average is not Fast Enough, indeed.

版权声明:本文为博主原创文章,未经博主允许不得转载。// p.s. If in any way improment can be achieved, better performance or whatever, it will be well-appreciated to let me know, thanks in advance.

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

  1. hdu 1053 (huffman coding, greedy algorithm, std::partition, std::priority_queue ) 分类: hdoj 2015-06-18 19:11 22人阅读 评论(0) 收藏

    huffman coding, greedy algorithm. std::priority_queue, std::partition, when i use the three commente ...

  2. Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  3. Hdu 1429 胜利大逃亡(续) 分类: Brush Mode 2014-08-07 17:01 92人阅读 评论(0) 收藏

    胜利大逃亡(续) Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Subm ...

  4. Hdu 1009 FatMouse' Trade 分类: Translation Mode 2014-08-04 14:07 74人阅读 评论(0) 收藏

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  5. HDU 1532 Drainage Ditches 分类: Brush Mode 2014-07-31 10:38 82人阅读 评论(0) 收藏

    Drainage Ditches Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  6. Hdu 1507 Uncle Tom's Inherited Land* 分类: Brush Mode 2014-07-30 09:28 112人阅读 评论(0) 收藏

    Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  7. HDU 1754 I Hate It 2016-09-14 19:01 27人阅读 评论(0) 收藏

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  8. Bzoj 1036 树的统计 分类: ACM TYPE 2014-12-29 18:55 72人阅读 评论(0) 收藏

    Description 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w.我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. Q ...

  9. sscanf 函数 分类: POJ 2015-08-04 09:19 4人阅读 评论(0) 收藏

    sscanf 其实很强大 分类: 纯C技术 技术笔记 2010-03-05 16:00 12133人阅读 评论(4) 收藏 举报 正则表达式stringbuffercurlgoogle 最近在做日志分 ...

随机推荐

  1. linux下cmake编译安装、配置和卸载mysql

    WIN10下虚拟机:VMware workstation 12 PRO 安装 # 1.查看系统版本 [root@vm-xiluhua][/home/xiluhua]$ cat /etc/redhat- ...

  2. 锁表 for update

    select for update 是为了在查询时,避免其他用户以该表进行插入,修改或删除等操作,造成表的不一致性. 举几个例子:select * from t for update 会等待行锁释放之 ...

  3. html里面的相对路径和绝对路径

    HTML有两种路径的写法:相对路径和绝对路径. 相对路径是在同一个目录的文件引用,如果源文件和引用文件在同一个目录里,直接写引用文件名即可. 如: a.html:     c:\test\menu\a ...

  4. Lost Cows(线段树 POJ2182)

    Lost Cows Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10354 Accepted: 6631 Descriptio ...

  5. Bootstrap_下拉菜单

    在使用Bootstrap框架的下拉菜单时,必须调用Bootstrap框架提供的bootstrap.js文件. 一.普通下拉菜单 <div class="dropdown"&g ...

  6. 利用RNAseq数据做聚类分析

    library(ConsensusClusterPlus)library(factoextra)library(cluster)library(NbClust)# 读入数据data = read.ta ...

  7. HDU-4528 小明系列故事——捉迷藏 BFS模拟

    题意:链接 分析:每一个D或者是E点往四面延伸,并且赋一个特殊的值,能看到D点的点赋值为1,能看到E点的点赋值为1000,这是因为最多100步,因此最后可以根据除以1000和对1000取模来得出某个状 ...

  8. iOS - Mac OS X 常用快捷键

    Mac OS X 常用快捷键 1)快捷键图标: Escape 为 esc 键 无 Eject 键时用电源键代替 Space Bar 为空格键 2)基本快捷键: command + x 剪切文字 com ...

  9. div 一段时间后自动隐藏

    一.div弹出后自动消失 这里并没有删除 setTimeout(function(){$(".alert").hide();},2000); 直接在js文件中需要的地方添加执行这段 ...

  10. openfire源码修改聊天消息发送内容

    /** * $RCSfile: MessageRouter.java,v $ * $Revision: 3007 $ * $Date: 2005-10-31 13:29:25 -0300 (Mon, ...