现在的位置: 首页 > 综合 > 正文

HEU 2023 Average is not Fast Enough!

2012年07月06日 ⁄ 综合 ⁄ 共 1201字 ⁄ 字号 评论关闭
 1/**************************************
 2Problem: HEU 2023 Average is not Fast Enough!
 3Time: 0.0070 s
 4Memory: 260 k 
 5Accepted Time: 2009-04-06 16:10:50
 6Tips: 还得加上0.5,满足精度 
 7**************************************/

 8#include <stdio.h>
 9int main()
10{
11    int n;
12    double d;
13    scanf("%d%lf",&n,&d);
14    int t;
15    while(scanf("%d",&t)!=EOF)
16    {
17        int i,flag=1,hour,min,sec;
18        char temp[20];
19        hour=min=sec=0;
20        for(i=0;i<n;i++)
21        {
22            scanf("%s",temp);
23            if(flag==1)
24            {
25                if(temp[0]=='-')flag=0;
26                else
27                {
28                    int hh,mm,ss;
29                    sscanf(temp,"%d:%d:%d",&hh,&mm,&ss);
30                    hour+=hh;
31                    min+=mm;
32                    sec+=ss;
33                }

34            }

35        }

36        printf("%3d: ",t);
37        if(flag==0)printf("-\n");
38        else
39        {
40            double sum=hour*60*60+min*60+sec;
41            sum/=d;
42            sum+=0.5;
43            int aa=(int)sum/60;
44            int bb=(int)(sum-60*aa);
45            printf("%d:%02d min/km\n",aa,bb);
46        }

47    }

48    return 0;
49}

50

抱歉!评论已关闭.