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 44 45 46 47 48 49 50 51 |
#include <iostream> #include <cstdio> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <cstdlib> #define INF 1000000 #define ll long long using namespace std; int main() { int kase=1; int n; double u,v,t,a,s; while(scanf("%d",&n),n) { if(n==1) { scanf("%lf%lf%lf",&u,&v,&t); a = (v-u)/t; s=u*t+.5*a*(t*t); printf("Case %d: %.3lf %.3lf\n",kase++,s,a); } else 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",kase++,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",kase++,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",kase++,u,t); } } return 0; } |