P16466 [GKS 2013 Practice] Captain Hammer 题解
斜抛运动水平射程公式:
对公式进行移项变形可得出:
令
由于正弦函数值域为 ,若 ,则取 ,保证有解。
AC code :
# include <bits/stdc++.h>//万能头文件
using namespace std;
int t;
double v,d;
int main () {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> t;
cout << fixed << setprecision(7);
for (int i = 1;i <= t;i++) {
cin >> v >> d;
double x = d * 9.8 / (v * v);
if(x > 1.0) x = 1.0;
cout << "Case #" << int(i) << ": " << 0.5 * asin(x) * 180.0 / acos(-1.0) << endl;//直接用公式写
}
return 0;
}