1004 of search
来源:互联网 发布:锐捷交换机端口聚合 编辑:程序博客网 时间:2024/06/08 17:53
Toxophily
Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 76 Accepted Submission(s) : 37
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.<br>We all like toxophily.<br><br>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?<br><br>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. <br>
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.<br>Technical Specification<br><br>1. T ≤ 100.<br>2. 0 ≤ x, y, v ≤ 10000. <br>
Output
For each test case, output the smallest answer rounded to six fractional digits on a separated line.<br>Output "-1", if there's no possible answer.<br><br>Please use radian as unit. <br>
Sample Input
3<br>0.222018 23.901887 121.909183<br>39.096669 110.210922 20.270030<br>138.355025 2028.716904 25.079551<br>
Sample Output
1.561582<br>-1<br>-1<br>
Source
The 4th Baidu Cup final
题目大意:一个人的射出箭初始速度一定,让你选择一个角度使恰好击中制定目标。若无法击中则输出-1.
解题思路:1随着角度的变化,在目标x的对应的y为先增大后减小,可以运用三分法进行迭代,最后求出近似解。
2直接用物理方法用三角函数表示出关系,直接用cmath的函数进行一次计算即可。
注意事项:三分法要判断是否能够打中目标
ps:用数学方法太容易了,只是推出公式可能acm中可欲不可求的。
#include<iostream>#include<cmath>#include<cstdio>using namespace std;int main(){ const double g=9.8; double x,y,v,s,s1,a,b; int n; scanf("%d",&n); while(n--) { scanf("%lf%lf%lf",&x,&y,&v); s=sqrt(x*x+y*y); a=atan(y/x); s1=v*v*(1-sin(a))/g/cos(a)/cos(a); if(s1<s)printf("-1\n"); else { b=(asin(s*g*cos(a)*cos(a)/v/v+sin(a))-a)/2; b=b+a; printf("%lf\n",b); } }}
0 0
- 1004 of search
- 1003 of search
- 1005 of search
- 1006 of search
- 1007 of search
- 1008 of search
- 1009 of search
- 1010 of search
- 1011 of search
- 1012 of search
- 1003 of search
- 1015 of search
- 1016 of search
- 1018 of search
- 1019 of search
- 1020 of search
- the summary of search
- Role of Internal Search
- Unicode、GBK、UTF-8小结
- LinkedHashSet类的使用
- bzoj2300【HAOI2011】防线修建
- 对Run-Time Check Failure #3 - The variable 'a' is being used without being initialized.的处理以及理解
- 隔行扫描
- 1004 of search
- bzoj1185【HNOI2007】最小矩形覆盖
- Visual Studio 性能分析工具 查找 线程死循环
- Binder学习笔记(一)
- 关于创建者模式
- 逐行扫描
- 浅谈JAVA中两种比较方式==和equals
- 第六章:面向对象的程序设计
- JAVA事务——事务特性