Average is not Fast Enough!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3436    Accepted Submission(s): 1348

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
 
Source
 
Recommend
 
 #include <stdio.h>
#include <string.h> char s[][];
int time[]; int main()
{
int N,n;
double d;
int num,i,j;
double res1;
int res2;
scanf("%d",&N);
scanf("%lf",&d);
memset(s,,sizeof(s));
while(scanf("%3d",&num)!=EOF)
{
int t=,totle=,k=;
//char h,m1,m2,s1,s2;
for(i=;i<N;i++)
{
getchar();
scanf("%s",s[i]);
//printf("%s\n",s[i]);
//scanf("%c:%c%c:%c%c",&h,&m1,&m2,&s1,&s2);
t=(s[i][]-'')*+(s[i][]-'')*+(s[i][]-'')*+(s[i][]-'')*+s[i][]-'';
//t=(h-'0')*3600+((m1-'0')*10+(m2-'0'))*60+(s1-'0')*10+(s2-'0');
if(t>)
{
totle+=t;
}
else
{
k=;
continue;
}
}
if(k==)
{
printf("%3d: -\n",num);
}
else
{
res2 = (int)totle*1.0/(d*);
res1 = (totle*1.0/(d*) - res2)*;
if(res1>=59.5)
{res2+=;res1=;}
printf("%3d:%2d:%02.0lf min/km\n",num,res2,res1);
}
}
//while(1);
return ;
}

网上不错的解法:

 #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_201311021335的更多相关文章

  1. opencv中的SIFT,SURF,ORB,FAST 特征描叙算子比较

    opencv中的SIFT,SURF,ORB,FAST 特征描叙算子比较 参考: http://wenku.baidu.com/link?url=1aDYAJBCrrK-uk2w3sSNai7h52x_ ...

  2. 基于Fast Bilateral Filtering 算法的 High-Dynamic Range(HDR) 图像显示技术。

    一.引言 本人初次接触HDR方面的知识,有描述不正确的地方烦请见谅. 为方便文章描述,引用部分百度中的文章对HDR图像进行简单的描述. 高动态范围图像(High-Dynamic Range,简称HDR ...

  3. Fast RCNN 训练自己的数据集(3训练和检测)

    转载请注明出处,楼燚(yì)航的blog,http://www.cnblogs.com/louyihang-loves-baiyan/ https://github.com/YihangLou/fas ...

  4. Fast RCNN 训练自己数据集 (2修改数据读取接口)

    Fast RCNN训练自己的数据集 (2修改读写接口) 转载请注明出处,楼燚(yì)航的blog,http://www.cnblogs.com/louyihang-loves-baiyan/ http ...

  5. 网格弹簧质点系统模拟(Spring-Mass System by Fast Method)附源码

    弹簧质点模型的求解方法包括显式欧拉积分和隐式欧拉积分等方法,其中显式欧拉积分求解快速,但积分步长小,两个可视帧之间需要多次积分,而隐式欧拉积分则需要求解线性方程组,但其稳定性好,能够取较大的积分步长. ...

  6. XiangBai——【AAAI2017】TextBoxes_A Fast Text Detector with a Single Deep Neural Network

    XiangBai--[AAAI2017]TextBoxes:A Fast Text Detector with a Single Deep Neural Network 目录 作者和相关链接 方法概括 ...

  7. 论文笔记--Fast RCNN

    很久之前试着写一篇深度学习的基础知识,无奈下笔之后发现这个话题确实太大,今天发一篇最近看的论文Fast RCNN.这篇文章是微软研究院的Ross Girshick大神的一篇作品,主要是对RCNN的一些 ...

  8. [转]Amazon DynamoDB – a Fast and Scalable NoSQL Database Service Designed for Internet Scale Applications

    This article is from blog of Amazon CTO Werner Vogels. -------------------- Today is a very exciting ...

  9. FAST特征点检测features2D

    #include <opencv2/core/core.hpp> #include <opencv2/features2d/features2d.hpp> #include & ...

随机推荐

  1. [Swift通天遁地]三、手势与图表-(4)3DTouch功能在项目中的应用

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  2. [Swift通天遁地]七、数据与安全-(3)Cocopods的安装和开源类库对JSON的解析

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  3. selenium3 + python - autoit上传文件

    一.环境准备: 1.可以autoit官网上下载,安装 http://www.autoitscript.com/site/ 2.AutoIt里面几个菜单功能介绍: SciTE Script Editor ...

  4. $P2126 Mzc家中的男家丁$

    problem #ifdef Dubug #endif #include <bits/stdc++.h> using namespace std; typedef long long LL ...

  5. mysql在linux下的安装(5.7版本以后)

    1.添加mysql组和mysql用户,用于设置mysql安装目录文件所有者和所属组. ①groupadd mysql ②useradd -r -g mysql mysql 2.将二进制文件解压到指定的 ...

  6. ACM_二维数组的查找

    二维数组的查找 Time Limit: 2000/1000ms (Java/Others) Problem Description: 给定一个n*m的二维数组,保证a[i][j] < a[i+1 ...

  7. Vue初识:一个前端萌新的总结

    一.前言 时隔三年,记得第一次写博客还是2015年了,经过这几年的洗礼,我也从一个后端的小萌新变成现在略懂一点点知识的文青.如今对于前端的东东也算有一知半解,个人能力总的来说,也能够独立开发产品级项目 ...

  8. MVC系列学习(九)-DTO的使用

    本次学习用的数据库,如下 1.什么是DTO:DataTransferObject 即数据传输对象,服务端的客户端的通信,自动定义个小的实体类,里面只包含我们需要传输的属性 2.不用DTO会有什么问题 ...

  9. Oracle12C用户创建、授权、登录

    Oracle12C用户创建.授权.登录 1.以系统用户登录 C:\Users\LEI>sqlplus sys/dwh as sysdba; SQL*Plus: Release 12.1.0.2. ...

  10. Mac下CUDA开启及Tensorflow-gpu 1.4 安装

    本文由@ray 出品,转载请注明出处.  文章链接:http://www.cnblogs.com/wolfray/p/8040694.html 在之前的文章中,笔者介绍了在Mac下安装Tensorfl ...