Toxophily
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.
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.
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.
23.901887 121.909183
110.210922 20.270030
2028.716904 25.079551
#include
#include
#define g 9.8
#define pi
3.1415926535897932384626433832795028841971693993751058209
//这次就不听pi精度还不够
double x,y,v;
double distance_y(double s)
{
return
v*sin(s)*x/(v*cos(s))-4.9*x*x/(v*cos(s)*v*cos(s));
}
int main()
{
//freopen("in.txt", "r", stdin);
double
mid1,mid2,first,endn,sum1,sum2;
int n;
scanf("%d",&n);
for(int
i=0;i
{
scanf("%lf%lf%lf",&x,&y,&v);
first=0;
endn=pi;//再大就反向Q了;
while(fabs(endn-first)>1e-8)//三分来判断最大的那个角度
{
mid1=first+(endn-first)/3;
mid2=endn-(endn-first)/3;
sum1=distance_y(mid1);
sum2=distance_y(mid2);
if(sum1>sum2)
endn=mid2;
else
first=mid1;
}
if(distance_y(first)
{
printf("-1\n");
continue;
}
first=0;
while(fabs(endn-first)>1e-8)//二分找最小值
{
mid1=(endn+first)/2;
sum1=distance_y(mid1);
if(sum1
first=mid1;
else
endn=mid1;
}
printf("%.6lf\n",endn);
}
}
Toxophily的更多相关文章
- HDU2298 Toxophily
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000作者博客:http://www.cnblogs.com/ljh2000-jump/转 ...
- HDU 2298 Toxophily
题目: Description The recreation center of WHU ACM Team has indoor billiards, Ping Pang, chess and bri ...
- HDU 2298 Toxophily(公式/三分+二分)
Toxophily Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- HDU 2298 Toxophily 【二分+三分】
一个人站在(0,0)处射箭,箭的速度为v,问是否能够射到(x,y)处,并求最小角度. 首先需要判断在满足X=x的情况下最大高度hmax是否能够达到y,根据物理公式可得 h=vy*t-0.5*g*t*t ...
- HDU -2298 Toxophily(三分法)
这道题目,可以推出物理公式直接来做,但是如果推不出来就必须用程序的一种算法来实现了,物理公式只是适合这一个或者某个题,但是这种下面这种解决问题的方法确实解决了一类问题 ----三分法,大家可能都听说过 ...
- HDU-2298 Toxophily (三分法入门系列)
题意: 意大利炮射出炮弹的速度为v,求在(0,0)击中(x,y)处的目标,发射炮弹的角度. 题解: 设f(α)表示角度为α时, f(α) = vsin(α) * t - 4.9 * t * t ① ...
- 【三分+精度问题】G. Toxophily
https://www.bnuoj.com/v3/contest_show.php?cid=9154#problem/G [题意] 已知人的坐标在(0,0),靶的位置在(x,y),人以速度v射箭并且射 ...
- HDU 2298:Toxophily(推公式)
http://acm.hdu.edu.cn/showproblem.php?pid=2298 题意:给出一个x,y,v,问从(0,0)以v为初速度射箭,能否射到(x,y)这个点,如果能,输出最小的射出 ...
- Toxophily HDU - 2298 三分+二分
代码+解析: 1 //题意: 2 //有一个大炮在(0,0)位置,为你可不可以把炮弹射到(x,y)这个位置 3 //题目给你炮弹初始速度,让你求能不能找出来一个炮弹射出时角度满足题意 4 //题解: ...
随机推荐
- 基于pytorch实现HighWay Networks之Train Deep Networks
(一)Highway Networks 与 Deep Networks 的关系 理论实践表明神经网络的深度是至关重要的,深层神经网络在很多方面都已经取得了很好的效果,例如,在1000-class Im ...
- LCA问题第二弹
LCA问题第二弹 上次用二分的方法给大家分享了对 LCA 问题的处理,各位应该还能回忆起来上次的方法是由子节点向根节点(自下而上)的处理,平时我们遇到的很多问题都是正向思维处理困难而逆向思维处理比较容 ...
- [err] 1055
本人mysql安装在ubuntu16.04上,mysql版本是5.7.19:在创建表和插入数据时报了 [Err] 1055 - Expression #1 of ORDER BY clause is ...
- 【京东账户】——Mysql/PHP/Ajax爬坑之产品列表显示
一.引言 实现京东的账户项目,功能模块之一,产品列表显示.要用到的是Apach环境,Mysql.PHP以及Ajax. 二.依据功能创建库.表.记录 创建库:jd 创建表:产品表 添加多条记录 /**产 ...
- VS2015 + EF6连接MYSQL
ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对应 (O/R Mapping) 解决方案,不仅支持SQL Server,还支持MySQL.Ora ...
- swift 开发学习问题
1 UITableViewController 问题: [UITableView dequeueReusableCellWithIdentifier:forIndexPath:], unable to ...
- Vuex 学习笔记
Vuex 是什么? Vuex 是一个专为 Vue.js应用程序开发的状态管理模式.由于SPA应用的模块化,每个组件都有它各自的数据(state).视图(view)和方法(actions),当项目内容越 ...
- appium启动运行log分析
1.手动启动appium 服务 > Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe ...
- 通过SQL脚本导入数据到不同数据库避免重复导入三种方式
前言 无论何种语言,一旦看见代码中有重复性的代码则想到封装来复用,在SQL同样如此,若我们没有界面来维护而且需要经常进行的操作,我们会写脚本避免下次又得重新写一遍,但是这其中就涉及到一个问题,这个问题 ...
- 80端口被system 占用
1 运行'netstat -ano'发现80端口被pid=4的进程占用 2 打开任务管理器,发现pid=4的进程,其实是system进程,其对应的进程描述是NT kernel & system ...