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. 处理mysql上百万条数据的优化

    php 处理上百万条的数据库如何提高处理查询速度 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字 ...

  2. c#委托、事件、Observer

    委托和事件在.NET Framework[1] 中的应用非常广泛,然而,较好地理解委托和事件对很多接触C#时间不长的人来说并不容易. 中文名 委托 外文名 Delegate 编程语言 C# 作     ...

  3. 纯CSS气泡效果

    http://www.liaoxuefeng.com/article/0013738937970388b6b6e5e5e2f4e21b65b01807c84ddf6000

  4. a标签样式

    .a{            cursor:pointer;            color: blue;            text-decoration:none;        }

  5. Android EditText 密码框默认是小圆点 怎么改成其它的(*)?

    text.setTransformationMethod(new AsteriskPasswordTransformationMethod()); public class AsteriskPassw ...

  6. lipo 合并target为Simulator和Device编译的静态库

    进入项目对应的Build目录后,以下指令: $lipo -create Debug-iphoneos/libSalamaDeveloper.a Debug-iphonesimulator/libSal ...

  7. sublime 自动编译

    Tools --> Build System --> New: { "shell_cmd": "cc.bat \"$file\"" ...

  8. [问题2015S11] 复旦高等代数 II(14级)每周一题(第十二教学周)

    [问题2015S11]  证明: 任一复方阵都相似于一个复对称阵. 举例说明: 存在实方阵, 它不相似于实对称阵. 问题解答请在以下网址下载:http://pan.baidu.com/share/ho ...

  9. [问题2014A10] 复旦高等代数 I(14级)每周一题(第十二教学周)

    [问题2014A10]  设 \(A\) 为 \(n\) 阶实方阵满足 \(AA'=I_n\) (即 \(A\) 为 \(n\) 阶正交阵), 证明: \[\mathrm{rank}(I_n-A)=\ ...

  10. Response.End()在Webform和ASP.NET MVC下的表现差异

    前几天在博问中看到一个问题--Response.End()后,是否停止执行?MVC与WebForm不一致.看到LZ的描述后,虽然奇怪于为何用Response.End()而不用return方式去控制流程 ...