HDU 2529.Shot
来源:互联网 发布:vb算法大全 编辑:程序博客网 时间:2024/05/22 02:29
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2529
AC代码(C++):
#include <iostream>#include <queue>#include <string>#include <algorithm>#define INF 0x3f3f3f3f#define eps 1e-8using namespace std;double h, l, v;const double g = 9.8;int main() { while (cin >> h >> l >> v) { if (h == 0 && l == 0 && v == 0)break; double a, b, c; a = c = -(g*l*l) / (2 * v*v); b = l; double ans = 4 * a*c - b*b; ans /= 4 * a; ans += h; printf("%.2lf\n", ans); } //system("pause");}总结: 用物理加速度位移公式做, 不过要把vx和vy表示成vcosθ和vsinθ, 最后才能转换成二次函数形式.
阅读全文