10281 - Average Speed
Moderator: Board moderators
-
- New poster
- Posts: 36
- Joined: Fri Dec 02, 2011 1:30 pm
- Location: Kaohsiung, Taiwan
Re: 10281 - Average Speed
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
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
-
- New poster
- Posts: 39
- Joined: Tue Aug 07, 2012 10:40 pm
- Location: BUBT,Dhaka, Bangladesh
- Contact:
Re: 10281 - Average Speed
Critical Input
Input:
Output:
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
Code: Select all
00:15:01 25.00 km
00:30:01 50.00 km
03:00:01 100.00 km
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
Re: 10281 - Average Speed
Code: Select all
Removed the code after getting AC
Last edited by techbd123 on Wed Aug 21, 2013 12:31 am, edited 2 times in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10281 - Average Speed
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
Check input and AC output for thousands of problems on uDebug!
Re: 10281 - Average Speed
Thanks to Guru! Brianfry
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10281 - Average Speed
Input:AC output:
Code: Select all
00:15:01
Code: Select all
00:15:01 0.00 km
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 48
- Joined: Sat Apr 06, 2013 6:02 pm
Re: 10281 - Average Speed
Thanks brianfry... 

-
- New poster
- Posts: 16
- Joined: Thu Oct 10, 2013 8:06 am
Re: 10281 - Average Speed
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10281 - Average Speed
Try using double instead of float
Check input and AC output for thousands of problems on uDebug!