10693 - Traffic Volume

All about problems in Volume 106. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
jagadish
Learning poster
Posts: 90
Joined: Mon Feb 16, 2004 8:53 pm
Location: Bangalore INDIA

10693 - Traffic Volume

Post by jagadish »

i am not able to understand if its a logical error or problem with floating points someone help me find the bug please..

[c]
code removed
[/c]
Last edited by jagadish on Thu Aug 05, 2004 7:51 am, edited 1 time in total.

prince56k
New poster
Posts: 33
Joined: Fri Dec 12, 2003 10:32 pm
Location: BANGLADESH

Post by prince56k »

The main problem is here: b=(2*f*60*sqrtl(2*f1*l1)+eps) ;
Think more about it. I replace your formula by mine and get AC. again it's a 2 line code and u needn't use eps at all.

jagadish
Learning poster
Posts: 90
Joined: Mon Feb 16, 2004 8:53 pm
Location: Bangalore INDIA

Post by jagadish »

thank you...i was so stupid not to notice that the previous formula was even dimensionally incorrect !
if u can think of it .. u can do it in software.

sunhong
New poster
Posts: 19
Joined: Sat Apr 12, 2003 6:13 pm
Location: China

Post by sunhong »

Here is my code. I calculate the sample output correctly,but got WA
many times.
Can anyone point out what is wrong in my code??
Last edited by sunhong on Fri Aug 06, 2004 7:28 am, edited 1 time in total.

jagadish
Learning poster
Posts: 90
Joined: Mon Feb 16, 2004 8:53 pm
Location: Bangalore INDIA

Post by jagadish »

here is some sample i/o that may help..
10 3
12 2
8 9
100 10000
5 3
0 0
correct output:
7.74596669 1394.27400463
6.92820323 1039.23048454
12.00000000 2700.00000000
1414.21356237 25455.84412272
5.47722558 1971.80120702

_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Need to understand it.

Post by _.B._ »

Thanks for helping!
Keep posting!
Last edited by _.B._ on Sun Aug 08, 2004 5:21 pm, edited 1 time in total.
_.

Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post by Larry »

You can write the volume in terms of the velocity, so that part shouldn't be so hard. As for the velocity, you know that max (and mins) happen when the slope (derivative) is 0. So you just have to find the function that describes that..

sv90
New poster
Posts: 17
Joined: Wed Feb 01, 2006 8:27 pm
Location: Dhaka,Bangladesh

Post by sv90 »

what will be the data type of this program

shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim »

sv90 wrote:what will be the data type of this program
double should do it.

sv90
New poster
Posts: 17
Joined: Wed Feb 01, 2006 8:27 pm
Location: Dhaka,Bangladesh

Post by sv90 »

sv90 wrote: this my code but i got WA!!!!!!!!!!!!!!!!!!
#include<stdio.h>
#include<math.h>

int main()
{
float V,volume;
float L,f;
while((scanf("%f%f",&L,&f))==2)
{
if((L==0)&&(f==0))
{
break;
}
V=sqrt(L*f*2.0);

volume=(V*3600)/(2*L);
printf("%.8f %.8f",V,volume);
}
return 0;
}

shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim »

Two changes are required to get AC.

Code: Select all

printf("%.8f %.8f",V,volume);
There should be a newline after each case of output.

Also, change all data types to double.

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun »

Would anybody kindly tell me how to make use of given L in this problem?

yeasin_acm_solver
New poster
Posts: 11
Joined: Wed Jun 09, 2010 2:30 pm
Location: University Of Science & Technology Chittagong (USTC) Bangladesh

Re: 10693 - Traffic Volume

Post by yeasin_acm_solver »

why i get wrong answer at this code:

PLZ Help Me.../*
Author : Muhammad Yeasin
University of Science & Technology Chittagong (USTC)
CSE- 11th Batch
Bangladesh Date: 5:32 AM 6/8/2010 UVA ID: 10693 Traffic Volume
*/
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#define pb push_back
#define file { freopen("input.txt","r",stdin);}

using namespace std;

int main()
{
int l,f;
//file
while(scanf("%d%d",&l,&f)==2){
if((l==0)&&(f==0))
break;
printf("%.8Lf ",sqrt(abs(l)*abs(f)*2.0));
if(f<0)
printf("-%.8Lf\n",(sqrt(abs(l)*abs(f)*2.0)*3600)/(2*abs(l)));
else
printf("%.8Lf\n",(sqrt(abs(l)*abs(f)*2.0)*3600)/(2*abs(l)));


}
return 0;
}



Post Reply

Return to “Volume 106 (10600-10699)”