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;
    }
  • 相关阅读:
    CodeForces C. Songs Compression
    CodeForces B. Obtaining the String
    Linux-命令学习-df
    phplib系统开发经验总结
    阶段3-团队合作项目-网络安全传输系统sprint1-传输子系统设计第3课-加密传输优化
    阶段3-团队合作项目-网络安全传输系统sprint1-传输子系统设计第2课-OpenSSL加密系统
    阶段3-团队合作项目-网络安全传输系统sprint1-传输子系统设计第1课-系统程序框架搭建
    阶段3-团队合作项目-网络安全传输系统sprint0-产品规划与设计第1课-产品功能展示
    阶段2-新手上路项目-移动物体监控系统Sprint4-嵌入式web服务器开发第3课-CGI程序开发
    阶段2-新手上路项目-移动物体监控系统Sprint4-嵌入式web服务器开发第2课-CGI快速入门-网页控制LED
  • 原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/5781649.html
Copyright © 2011-2022 走看看