HEU 2023 Average is not Fast Enough!
1
/**************************************
2
Problem: HEU 2023 Average is not Fast Enough!
3
Time: 0.0070 s
4
Memory: 260 k
5
Accepted Time: 2009-04-06 16:10:50
6
Tips: 还得加上0.5,满足精度
7
**************************************/
8
#include <stdio.h>
9
int 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
/**************************************2
Problem: HEU 2023 Average is not Fast Enough!3
Time: 0.0070 s4
Memory: 260 k 5
Accepted Time: 2009-04-06 16:10:506
Tips: 还得加上0.5,满足精度 7
**************************************/8
#include <stdio.h>9
int 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
else27
{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
else39
{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




浙公网安备 33010602011771号