UVa 11715: Car

Problem Link


<Source Code>

#include<stdio.h>
#include<math.h>
int main()
{
int n, i=1;
double u, v, t, a, s, V, U;
while(scanf(“%d”, &n)==1)
{
if(n==1)
{
scanf(“%lf%lf%lf”, &u, &v, &t);
a=(v-u)/t;
s=(u*t)+((1/2.0)*a*t*t);
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=(u*t)+((1/2.0)*a*t*t);
printf(“Case %d: %.3lf %.3lf\n”, i, s, t);
}
else if(n==3)
{
scanf(“%lf%lf%lf”, &u, &a, &s);
V=(u*u)+(2*a*s);
v=sqrt(V);
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=(v*v)-(2*a*s);
u=sqrt(U);
t=(v-u)/a;
printf(“Case %d: %.3lf %.3lf\n”, i, u, t);
}
else
break;
i++;
}
return 0;
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s