-
Notifications
You must be signed in to change notification settings - Fork 0
/
UVA 11715.cpp
43 lines (43 loc) · 985 Bytes
/
UVA 11715.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<stdio.h>
#include<math.h>
int main()
{
double n,b,c,d,u,v,s,t,a;
int cs=1;
while(scanf("%lf",&n)==1)
{
if(n==0)
break;
scanf("%lf%lf%lf",&b,&c,&d);
if(n==1)
{
u=b,v=c,t=d;
a=(v-u)/t;
s=(u*t)+(0.5*a*(t*t));
printf("Case %d: %.3lf %.3lf\n",cs,s,a);
}
else if(n==2)
{
u=b,v=c,a=d;
t=(v-u)/a;
s=(u*t)+(0.5*a*t*t);
printf("Case %d: %.3lf %.3lf\n",cs,s,t);
}
else if(n==3)
{
u=b,a=c,s=d;
v=sqrt((2*a*s)+(u*u));
t=(v-u)/a;
printf("Case %d: %.3lf %.3lf\n",cs,v,t);
}
else if(n==4)
{
v=b,a=c,s=d;
u=sqrt((v*v)-(2*a*s));
t=(v-u)/a;
printf("Case %d: %.3lf %.3lf\n",cs,u,t);
}
cs++;
}
return 0;
}