hoj2298Toxophily【二分+三分】
来源:互联网 发布:淘宝pc端首页焦点图 编辑:程序博客网 时间:2024/06/04 17:48
Toxophily
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1511 Accepted Submission(s): 790
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
30.222018 23.901887 121.90918339.096669 110.210922 20.270030138.355025 2028.716904 25.079551
Sample Output
1.561582-1-1
题意:给定水果的坐标一个人站在(0,0)的位置射该苹果问仰角多大
解题思路:因为射出后的足迹为抛物线只需判断该点是否在该抛物线上即可因为要射中则该点必须在上升过程;由此利用三分法确定仰角的范围;之后再二分确定角度
#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#define eps 1e-8#define G 9.8 #include<algorithm>#define PI 3.1415926535897932using namespace std;double x,y,v;int sgn(double n){if(fabs(n))return 0;else if(n<0)return 1;return 1;}double gety(double angle){double t=x/(v*cos(angle));return v*sin(angle)*t-0.5*G*t*t;}void Bina(double angle){double left=0,right=angle;int size=100;while(size--){double mid=(left+right)/2.0;if(gety(mid)>y)right=mid;elseleft=mid;}printf("%.6lf\n",left);}void Three(){double mid,mmid;double left=0,right=PI/2.0;double h1,h2;int size=100;while(size--){mid=(left+right)/2.0;mmid=(mid+right)/2.0;h1=gety(mid);h2=gety(mmid);if(h1>h2)right=mmid;else left=mid;}double cnt=gety(left);if(cnt<y)printf("-1\n");else Bina(left);}int main(){int t,i,j,k;scanf("%d",&t);while(t--){scanf("%lf%lf%lf",&x,&y,&v);Three();}return 0;}
0 0
- hoj2298Toxophily【二分+三分】
- 二分&三分
- hdu2298 Toxophily 三分+二分
- hdu2298 三分+二分查找
- Training 二分\三分
- Toxophily(hdu2298三分+二分)
- 二分和三分模板
- 二分查找 三分查找
- 二分查找,三分查找
- 二分、三分总结
- hdu 2298 二分+三分
- 二分+三分模板
- 二分三分小结
- 二分三分u1597
- 二分与三分
- 算法笔记--二分/三分
- hdu2899 简单数学+二分+三分
- hdu2899 Strange fuction (二分&三分)
- Spring获取XML
- Android 面试 基础
- hdu3037 Saving Beans(个数可为0的特殊“插板法”+推公式+组合数取摸(需预处理素数阶乘,否则TLE))
- JobTracker和TaskTracker概述
- Swift2.0新特性
- hoj2298Toxophily【二分+三分】
- 一只简单的网络爬虫(基于linux C/C++)————线程相关
- js修改title
- iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(一)
- java 适配器模式
- java学习笔记IO输入与输出——IO流概述及字节流(2)
- 深入详解Struts2——Struts2初识
- JavaScript面向对象(3)
- NYOJ 891 找点 (贪心&区间选点)