博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Problem G
阅读量:5880 次
发布时间:2019-06-19

本文共 2504 字,大约阅读时间需要 8 分钟。

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
题意:这题很水,给出总共跑几圈,每圈的用时,求出一千米多少时间;
解题思路:这个题很水,刚开始看的时候,一看输入输出就不想做了,里面有时间,很麻烦,就放到最后写,心思这用类写。。。。我去,看懂题意之后(全是脏话),这么水,就是输入输出有点难度,用cin的话可以免去很多不必要的麻烦;
感悟:水题(老师0.0,以后输入输出弄得容易看点都乱码了)
代码(G++ 15MS)
#include
#include
using namespace std;
int main()
{
   
    //freopen("in.txt", "r", stdin);
    int n,t,h,m,s,time_s;
    double d;
    bool flag;
    scanf("%d %lf",&n,&d);
    while(cin>>t)
    {
        flag=1;
        time_s=0;
        for(int i=0;i
        {
            char str;
            cin>>str;
            if(str=='-')
            {
                cin>>str>>str>>str>>str>>str>>str;
                flag=0;
                continue;
            }
            else
            {
                scanf("%*c%d%*c%d",&m,&s);//%*c的意思就是跳过这个不输入了
                time_s+=(s+m*60+(str-'0')*3600);
            }
        }
        if(!flag)
            printf("=: -\n", t);
   

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/5781650.html

你可能感兴趣的文章
AWS的redhat7中安装jdk8
查看>>
Hadoop 之 Sqoop 安装配置与示例
查看>>
Redis后台监控与管理CacheCloud
查看>>
[20171124]xxd与通配符.txt
查看>>
C# - 设计模式 - 适配器模式
查看>>
Mageia 3 Beta 4 发布,Linux 发行版
查看>>
Python基础语法(三)
查看>>
BZOJ 物流运输
查看>>
量子行走
查看>>
12月centos单词
查看>>
20172317 《程序设计与数据结构》 第二周学习总结
查看>>
文件格式相关开源项目
查看>>
java中goto语句!
查看>>
java内存模型二
查看>>
读书笔记-- --JavaScript王者归来
查看>>
吴忠军的Q友乐园主页
查看>>
吴忠军全民k歌主页
查看>>
mybaits 学习
查看>>
su: Authentication failure
查看>>
java继承(翻译自Java Tutorials)
查看>>