利用計算速度的物理公式以及僅知的參數去求出答案即可。我是用其中的兩個公式再去推導的:
\(
\begin{align}
v & = u + a \times t \newline
S & = u \times t + \frac{1}{2} \times a \times t^{2}
\end{align}
\)
關鍵字:等加速度直線運動
C++(0.000)
/*******************************************************/
/* UVa 11715 Car */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2018/05/18 */
/*******************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
int type;
int caseNumber = 1;
while(scanf("%d", &type) != EOF && type != 0){
printf("Case %d: ", caseNumber++);
double u, v, t, a, s;
switch(type){
case 1:
scanf("%lf%lf%lf", &u, &v, &t);
a = (v - u) / t;
s = (u + v) * t / 2;
printf("%.3lf %.3lf", s, a);
break;
case 2:
scanf("%lf%lf%lf", &u, &v, &a);
t = (v - u) / a;
s = (u + v) * t / 2;
printf("%.3lf %.3lf", s, t);
break;
case 3:
scanf("%lf%lf%lf", &u, &a, &s);
v = sqrt(u * u + 2 * a * s);
t = (v - u) / a;
printf("%.3lf %.3lf", v, t);
break;
case 4:
scanf("%lf%lf%lf", &v, &a, &s);
u = sqrt(v * v - 2 * a * s);
t = (v - u) / a;
printf("%.3lf %.3lf", u, t);
break;
}
printf("\n");
}
return 0;
}