Page 3 of 3

### Re: 10281 - Average Speed

Posted: Wed Aug 15, 2012 7:27 pm
I get AC now~
But it's not a precision problem
it's a input problem with the first line
it's not necessary to have a "speed" input at the end of the first line
Thank you very for your help !!!
I really appreciate it

### Re: 10281 - Average Speed

Posted: Tue Jan 01, 2013 5:53 pm
Critical Input

Input:

Code: Select all

``````00:00:01 100
00:15:01
00:30:01
01:00:01 0
03:00:01
03:00:05 140``````
Output:

Code: Select all

``````00:15:01 25.00 km
00:30:01 50.00 km
03:00:01 100.00 km``````

### Re: 10281 - Average Speed

Posted: Sun Aug 18, 2013 1:31 am

Code: Select all

``Removed the code after getting AC``

### Re: 10281 - Average Speed

Posted: Mon Aug 19, 2013 10:08 pm
tzupengwang wrote:I get AC now~
But it's not a precision problem
it's a input problem with the first line
it's not necessary to have a "speed" input at the end of the first line
Thank you very for your help !!!
I really appreciate it

### Re: 10281 - Average Speed

Posted: Wed Aug 21, 2013 12:29 am
Thanks to Guru! Brianfry

### Re: 10281 - Average Speed

Posted: Tue Oct 08, 2013 12:35 am
Input:

Code: Select all

``````00:15:01
``````
AC output:

Code: Select all

``````00:15:01 0.00 km
``````

### Re: 10281 - Average Speed

Posted: Wed Dec 04, 2013 11:28 am
Thanks brianfry...

### Re: 10281 - Average Speed

Posted: Sun Dec 29, 2013 6:09 pm

Code: Select all

``````#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{

int speed,first,temp,second,len,i;
float total=0;
char time[20];
while(gets(time))
{
len=strlen(time);
if(len<9)
{
second=((time[0]-'0')*10+time[1]-'0')*3600+((time[3]-'0')*10+time[4]-'0')*60+(time[6]-'0')*10+time[7]-'0';
total+=((second-first)*speed)/3600;
printf("%s %.2f km\n", time, total);
first=second;
}
else
{
second=((time[0]-'0')*10+time[1]-'0')*3600+((time[3]-'0')*10+time[4]-'0')*60+(time[6]-'0')*10+time[7]-'0';
total+=((second-first)*speed)/3600;
speed=0;
temp=len-1;
i=1;
while(temp>8)
{
speed+=(time[temp]-'0')*i;
i=i*10;
temp--;
}
first=second;
}

}
return 0;
}
``````
i am getting wrong answer. but my code give sample output. please help me.

### Re: 10281 - Average Speed

Posted: Wed Jan 15, 2014 1:21 am
Try using double instead of float

### Re: 10281 - Average Speed

Posted: Tue May 13, 2014 12:34 pm
brianfry713 and alimbubt,

Thanks for the great test cases.