11715 - Car

All about problems in Volume 117. 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
sms.islam
New poster
Posts: 19
Joined: Sat Oct 10, 2009 10:28 am

11715 - Car

Post by sms.islam »

I have got WA for this problem.Is there any trick with that problem?

can anyone please send some spical input for this problem?

my algorithom()
{
while(scanf("%ld",&n)!=EOF)
{
if(n==1)
{
print desired result;
}

else if(n==1)
{
print desired result;
}

else if(n==1)
{
print desired result;
}
.................................................
}
}

whats wrong with that?
r2ro
New poster
Posts: 38
Joined: Thu Sep 25, 2008 9:26 am

Re: 11715 : Car problem

Post by r2ro »

Well, why are your conditional statements only if n == 1?
naseefcuet
New poster
Posts: 2
Joined: Mon Jul 20, 2009 6:53 am

Re: 11715 : Car problem

Post by naseefcuet »

@sms.islam
post your code.....This is a simple problem....there should be some sill ymistakes in your code.... :)
sms.islam
New poster
Posts: 19
Joined: Sat Oct 10, 2009 10:28 am

Re: 11715 : Car problem

Post by sms.islam »

// Code removed cause Accepted

thanx naseefcuet i got it.
Last edited by sms.islam on Sun Nov 22, 2009 6:33 pm, edited 1 time in total.
naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm
Location: CUET,Chittagong,Bangladesh

Re: 11715 : Car problem

Post by naseef_07cuet »

@s.islam
check this code...and make the correction from your code:-:
read (c);
if(c==0)
break;
if(c==1)
read (u,v,t);
a=(v-u)/t;
s=(v*v-u*u)/(2*a);
if(c==2)
read(u,v,a);
t=(v-u)/a;
s=(v*v-u*u)/(2*a);
if(c==3)
read(u,a,s);
v=sqrt((u*u+2*a*s));
t=(v-u)/a;
else if(c==4)
read(v,a,s);
u=sqrt((v*v-2*a*s));
t=(v-u)/a;
Hope you will get it........
If you have determination, you can do anything you want....:)
Eather
New poster
Posts: 28
Joined: Thu Jan 28, 2010 2:23 pm

Re: 11715 : Car problem

Post by Eather »

why WA?? i got AC with the same code once i submitted 1st time.

Code: Select all

#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;

int main() 
{
 	int n;
 	long double a, b, c;
 	int i = 1;
 	while ((scanf("%d %lf %lf %lf",&n,&a,&b,&c))==4) 
	{
 		if (n == 1) 
		{
 			long double res2 = (b-a)/c;
 			long double res1 = (a*c) + (0.5*res2*c*c);
 			printf("Case %d: %0.3lf %0.3lf\n", i, res1, res2);
 		}
 		if (n == 2) 
		{
 			long double res2 = (b-a)/c;
 			long double res1 = (a*res2) + (0.5*c*res2*res2);
 			printf("Case %d: %0.3lf %0.3lf\n", i, res1, res2);
 		}
 		if (n == 3) 
		{
 			long double res1 = sqrt(a*a + 2*b*c);
 			long double res2 = (res1-a)/b;
 			printf("Case %d: %0.3lf %0.3lf\n", i, res1, res2);
 		}
 		if (n == 4) 
		{
 			long double res1 = sqrt(a*a - 2*b*c);
 			long double res2 = (a-res1)/b;
 			printf("Case %d: %0.3lf %0.3lf\n", i, res1, res2);
 		}
 		i++;
 	}
 
 }
help me please
vkshibbir
New poster
Posts: 1
Joined: Tue Sep 06, 2011 6:49 pm

Re: 11715 - Car

Post by vkshibbir »

Why WA?

Code: Select all

#include<stdio.h>
#include<math.h>

int main()
{
    int i;
    int a;
    double  b,c,d;
    double  u,v,ac,s,t;
    for(i=1;; i++)
    {
        scanf("%d",&a);
        if(a==0)break;
        scanf("%lf %lf %lf",&b,&c,&d);

        printf("Case %d: ",i);

        if(a==1)
        {
            u=b;
            v=c;
            t=d;
            ac=(v-u)/t;
            s=u*t+.5*ac*t*t;
            printf("%.3lf %.3lf\n",s,ac);
        }
        if(a==2)
        {
            u=b;
            v=c;
            ac=d;
            s=(v*v-u*u)/(2*ac);
            t=(v-u)/a;
            printf("%.3lf %.3lf\n",s,t);
        }
        if(a==3)
        {
            u=b;
            ac=c;
            s=d;
            v=sqrt((u*u+2*ac*s));
            t=(v-u)/ac;
            printf("%.3lf %.3lf\n",v,t);
        }
        if(a==4)
        {
            v=b;
            ac=c;
            s=d;
            u=sqrt(v*v-2*ac*s);
            t=(v-u)/ac;
            printf("%.3lf %.3lf\n",u,t);
        }
    }
    return 0;
}
help me please
reza_uranium
New poster
Posts: 2
Joined: Fri Feb 01, 2013 4:12 pm

Re: 11715 - Car

Post by reza_uranium »

Why WA...plz help me :(

Code: Select all

#include <stdio.h>
#include <math.h>

int main()
{
    int i,n;
    double s,a,u,v,t;

    for(i=1;;i++){
        scanf("%d",&n);

        if(n==0){
            break;
        }

        if(n==1){
            scanf("%lf %lf %lf",&u,&v,&t);

            s=((u+v)/2.0)*t;
            a=(v-u)/t;

            printf("Case %d: %.3lf %.3lf\n",i,s,a);
        }
        if(n==2){
            scanf("%lf %lf %lf",&u,&v,&a);

            t=(v-u)/a;
            s=u*t+.5*a*t*t;

            printf("Case %d: %.3lf %.3lf\n",i,s,t);
        }
        if(n==3){
            scanf("%lf %lf %lf",&u,&a,&s);

            v=sqrt(2*a*s+u*u);
            t=(v-u)/a;

            printf("Case %d: %.3lf %.3lf\n",i,v,t);
        }
        if(n==4){
            scanf("%lf %lf %lf",&v,&a,&s);

            u=sqrt(u*u-2*a*s);
            t=(v-u)/a;

            printf("Case %d: %.3lf %.3lf\n",i,u,t);
        }
    }

    return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11715 - Car

Post by brianfry713 »

Input:

Code: Select all

3 6 1 6
4 5.0 -1 6
0
AC output:

Code: Select all

Case 1: 6.928 0.928
Case 2: 6.083 1.083
Check input and AC output for thousands of problems on uDebug!
raj
Learning poster
Posts: 78
Joined: Fri Feb 15, 2013 5:39 pm

Re: 11715 - Car

Post by raj »

Deleted
Last edited by raj on Tue Mar 05, 2013 11:48 pm, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11715 - Car

Post by brianfry713 »

See what happens with 10 or more input cases.
Check input and AC output for thousands of problems on uDebug!
raj
Learning poster
Posts: 78
Joined: Fri Feb 15, 2013 5:39 pm

Re: 11715 - Car

Post by raj »

thanks sir Now its accepted :)
liya
New poster
Posts: 10
Joined: Fri Jan 23, 2015 2:36 pm

Re: 11715 - Car

Post by liya »

WA.....what's wrong with this?

Code: Select all

#include<stdio.h>
#include<math.h>
int main()
{
   double u,v,a,s,t,re;
   int n,i;
    for(i=1; ;i++)
    {
        scanf("%d",&n);
        if(n==0)
        {
            break;
        }
        if(n==1)
        {
            scanf("%lf %lf %lf",&u,&v,&t);
            a=(v-u)/t;
            s=((v*v)-(u*u))/(2*a);
            printf("Case %d: %.3lf %.3lf\n",i,s,a);

        }
        else if(n==2)
        {
            scanf("%lf %lf %lf",&u,&v,&a);
            t=(v-u)/a;
            s=((v*v)-(u*u))/(2*a);
            printf("Case %d: %.3lf %.3lf\n",i,s,t);
        }
        else if(n==3)
        {
            scanf("%lf %lf %lf",&u,&a,&s);
            v=sqrt((u*u)+(2*a*s));
            t=(v-u)/a;
            printf("Case %d: %.3lf %.3lf\n",i,v,t);

        }
        else if(n==4)
        {
            scanf("%lf %lf %lf",&v,&a,&s);
            u=sqrt((v*v)-(2*a*s));
            t=(v-u)/a;
            printf("Case %d: %.3lf %.3lf\n",i,u,t);
        }
    }
    return 0;
}
Last edited by brianfry713 on Tue Jan 27, 2015 9:24 pm, edited 1 time in total.
Reason: Added code blocks
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11715 - Car

Post by brianfry713 »

That is AC code.
Check input and AC output for thousands of problems on uDebug!
liya
New poster
Posts: 10
Joined: Fri Jan 23, 2015 2:36 pm

Re: 11715 - Car

Post by liya »

thanks :) brianfry713
Post Reply

Return to “Volume 117 (11700-11799)”