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

本文共 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/5781649.html

你可能感兴趣的文章
MoSQL
查看>>
Hibernate多对一外键单向关联(Annotation配置)
查看>>
《CLR via C#》读书笔记 之 方法
查看>>
设计模式:组合模式(Composite Pattern)
查看>>
ContentValues 和HashTable区别
查看>>
LogicalDOC 6.6.2 发布,文档管理系统
查看>>
给PowerShell脚本传递参数
查看>>
实战2——Hadoop的日志分析
查看>>
利用FIFO进行文件拷贝一例
查看>>
Ecshop安装过程中的的问题:cls_image::gd_version()和不支持JPEG
查看>>
resmgr:cpu quantum等待事件
查看>>
一个屌丝程序猿的人生(六十六)
查看>>
Java 编码 UTF-8
查看>>
SpringMVC实战(注解)
查看>>
关于静态属性和静态函数
查看>>
进程的基本属性:进程ID、父进程ID、进程组ID、会话和控制终端
查看>>
spring+jotm+ibatis+mysql实现JTA分布式事务
查看>>
MyBatis启动:MapperStatement创建
查看>>
调查问卷相关
查看>>
eclipse启动无响应,老是加载不了revert resources,或停留在Loading workbench状态
查看>>