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. Yii2.0中文开发向导——Where条件查询全解析

    在Yii的Model里进行查询的时候 where是必不可少的.Where方法声明为 static where( $condition ) 其中参数 $condition类型为字符串或者数组 1.字符串 ...

  2. [caffe]linux下安装caffe(无cuda)以及python接口

    昨天在mac上折腾了一天都没有安装成功,晚上在mac上装了一个ParallelDesktop虚拟机,然后装了linux,十分钟就安装好了,我也是醉了=.= 主要过程稍微记录一下: 1.安装BLAS s ...

  3. Turtlebot入门篇

    0.什么是TurtleBot? 我自己的理解就是:TurtleBot是一款移动机器人,就是主要研究让机器人自主决定应该想那个方向走,怎么绕过障碍物,最终到达目的地.与之对应还有很多机器人,比如goog ...

  4. 连续最短路算法(Successive Shortest Path)(最小费用最大流)

    #include <cstdio> #include <cstring> #include <queue> #include <vector> #inc ...

  5. Web_add_header

    如果你发现所有的HTTP send请求都缺少头数据包,在脚本中的开头添加web_add_auto_header(”XXXXX“,”yyyy“);随着web_add_auto_header的添加,你不需 ...

  6. python学习总结1

    1.python环境搭建 1.下载python并安装,下载地址:http://pan.baidu.com/s/1jHpWblk 2.启动idle即可编辑python代码 2.基本语法 1.注释:单行注 ...

  7. How To Use FETCH_RECORDS In Oracle Forms

    When called from an On-Fetch trigger, initiates the default Form Builder processing for fetching rec ...

  8. 高宽不定的div相对父div上下、左右居中

    <div class="parent"> <div class="child">123</div> </div> ...

  9. 《BI项目笔记》创建父子维度

    创建步骤: 而ParentOriginID其实就是对应的ParentOriginID,它的 Usage 必须是 Parent 才能表示这样的一个父子维度. 查看OriginID属性, Usage 是 ...

  10. Java处理excel文件

    好久好久没写blog了,感觉都生锈了,最近弄了弄java处理excel,特来简单粘贴一下: package excel; import java.io.BufferedInputStream; imp ...