zoukankan      html  css  js  c++  java
  • Problem G

    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("=: - ", t);
            else
            {
                int ave=1.0*time_s/d+0.5;
                m=ave/60;
                s=ave`;
                printf("=: %d:d min/km ", t, m, s);
            }
        }
        return 0;
    }
  • 相关阅读:
    Java中extends和implements区别【杭州多测师】【杭州多测师_王sir】
    以下字符串,如果单词以辅音字母开头,则把辅音字母挪到最后,并在末尾加上“ay”。 如果以元音字母开头,则在末尾加上“hay”。 元音字母是“a.e.i.o.u” 字符串是“My name is Shopline,and i am 2,0000 days old”【杭州多测师】【杭州多测师_王sir】
    Linux环境下,请用一条命令计算出request.log文件中所有包含“requestDate”但是不包含“error”的行数【杭州多测师】【杭州多测师_王sir】
    主机重启hosts配置失效原因
    DNS BIND区域数据文件
    dns主从及智能dns搭建
    nginx 添加免费https证书
    nginx变量参数
    nginx last break详解
    常用工具下载地址
  • 原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/5781649.html
Copyright © 2011-2022 走看看