HDU-1036 Average is not Fast enough!

Source: Internet
Author: User
Tags integer numbers

Average is not Fast enough!

http://acm.hdu.edu.cn/showproblem.php?pid=1036

Problem Descriptiona Relay is a race for, or more teams of runners. Each member of a team runs one section of the race. Your task is to help evaluate the results of a relay race.

You have to process several teams. The for each team is given a list with the running times for every sections of the race. You is 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. on the "SOLA" relay in Zurich, Switzerland. For more information visit Http://www.sola.asvz.ethz.ch/after the contest are over.

Inputthe first line of the input specifies the number of sections n followed by the total distance of the relay D in Kilom Eters. Safely assume that 1 <= n <= 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 of the sections, separated by a single space. These running times is given in the format "H:mm:ss" with an integer numbers for the hours, minutes and seconds, Respectivel Y. In the special case of a runner being disqualified, the running time would be denoted by "-:--:--". Finally, the data on every line was terminated by a newline character. Input is terminated by EOF.

Outputfor Each team output exactly one line giving the team's number T right aligned in a field of width 3, and the Averag E 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 Input2 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:-7:6:00 min/km

#include <stdio.h>intMain () {intN; DoubleD; intnum; Charh,m1,m2,s1,s2; scanf ("%d",&N); scanf ("%LF",&d);  while(SCANF ("%d", &num)! =EOF) {printf ("%3d:", num); BOOLflag=true; intSumtime=0;  for(intI=0; 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'0')*3600+ ((m1-'0')*Ten+ (m2-'0'))* -+ (s1-'0')*Ten+ (s2-'0'); }            if(flag==false) printf ("-\n"); Else        {            Doublet1=sumtime/D; intT2= (int) (t1+0.5); printf ("%d:%02d min/km\n", t2/ -, t2% -); }        }        return 0;} 

HDU-1036 Average is not Fast enough!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.