HDU 2298 Toxophily(三分+二分)
来源:互联网 发布:依阿华级战列舰 知乎 编辑:程序博客网 时间:2024/05/22 08:12
传送门
Toxophily
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2304 Accepted Submission(s): 1270
Problem Description
The recreation center of WHU ACM Team has indoor billiards, Ping Pang, chess and bridge, toxophily, deluxe ballrooms KTV rooms, fishing, climbing, and so on.
We all like toxophily.
Bob is hooked on toxophily recently. Assume that Bob is at point (0,0) and he wants to shoot the fruits on a nearby tree. He can adjust the angle to fix the trajectory. Unfortunately, he always fails at that. Can you help him?
Now given the object’s coordinates, please calculate the angle between the arrow and x-axis at Bob’s point. Assume that g=9.8N/m.
We all like toxophily.
Bob is hooked on toxophily recently. Assume that Bob is at point (0,0) and he wants to shoot the fruits on a nearby tree. He can adjust the angle to fix the trajectory. Unfortunately, he always fails at that. Can you help him?
Now given the object’s coordinates, please calculate the angle between the arrow and x-axis at Bob’s point. Assume that g=9.8N/m.
Input
The input consists of several test cases. The first line of input consists of an integer T, indicating the number of test cases. Each test case is on a separated line, and it consists three floating point numbers: x, y, v. x and y indicate the coordinate of the fruit. v is the arrow’s exit speed.
Technical Specification
1. T ≤ 100.
2. 0 ≤ x, y, v ≤ 10000.
Technical Specification
1. T ≤ 100.
2. 0 ≤ x, y, v ≤ 10000.
Output
For each test case, output the smallest answer rounded to six fractional digits on a separated line.
Output "-1", if there’s no possible answer.
Please use radian as unit.
Output "-1", if there’s no possible answer.
Please use radian as unit.
Sample Input
3
0.222018 23.901887 121.909183
39.096669 110.210922 20.270030
138.355025 2028.716904 25.079551
Sample Output
1.561582
-1
-1
题目大意:
将其简化为:一个小球以初速度
解题思路:
此题为一高中物理题,可以通过分解速度,然后直接求其夹角,当然我们现在为了节约时间,让程序帮我们求夹角,在纸上还得推一下。
将
分别在横纵坐标上列两个方程:
将
令
代码:
#include <bits/stdc++.h>using namespace std;const double PI = acos(-1);const double eps = 1e-8;double X, Y, V;double f(double x){ double ans = X*tan(x)-4.9*(X/(V*cos(x)))*(X/(V*cos(x)))-Y; return ans;}double sanfen(double left, double right){ double midl, midr; while (right-left > eps){ midl = (left + right) / 2; midr = (midl + right) / 2; if(f(midl) >= f(midr)) right = midr; else left = midl; } return left;}double erfen(double left, double right){ while(right-left > eps){ double mid = (left + right) * 0.5; if(f(mid) < -eps) left = mid; else right = mid; } return right;}int main(){ int T; scanf("%d", &T); while(T--){ scanf("%lf%lf%lf",&X,&Y,&V); double tm = sanfen(0,0.5*PI); if(f(tm) < -eps) { puts("-1"); continue; } printf("%.6f\n",erfen(0, tm)); } return 0;}
阅读全文
0 0
- HDU 2298 Toxophily(三分+二分)
- hdu 2298 Toxophily 公式 或者 三分+二分。
- HDU 2298 Toxophily(公式/三分+二分)
- HDU2298:Toxophily(三分 + 二分)
- hdu 2298 - Toxophily [二分]
- hdu2298 Toxophily 三分+二分
- Toxophily(hdu2298三分+二分)
- Toxophily-数论以及二分三分
- hdoj 2298 Toxophily(数学推导或三分+二分)
- HDU 2298 Toxophily 二分 推公式
- hdu 2298 二分+三分
- 【hdu2298】Toxophily——三分+二分
- HDU 2298 Toxophily(水~)
- HDU 2298 Toxophily
- hdu 2298 Toxophily
- HDU 2298 Toxophily
- HDU 2298 Toxophily
- hdu 2298 Toxophily (物理题)
- RocketMQ原理解析-namesrv
- DOM
- 相对路径与绝对路径个人理解
- 给duilib增加脚本支持
- 杭电acm1785 求坐标夹角排序
- HDU 2298 Toxophily(三分+二分)
- 代码质量管理平台Sonar的安装、使用
- 汉诺塔(一)
- MySQL拼接分组查询(查询一天的数据)
- hdu 6097 Mindis(多校联赛)
- mysql复制之HeartBeat介绍和裂脑
- HDU-6103 Kirinriki
- L2-024. 部落
- LinkList01