HDU2298 Toxophily
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作。
本文作者:ljh2000
作者博客:http://www.cnblogs.com/ljh2000-jump/
转载请注明出处,侵权必究,保留最终解释权!
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.
Technical Specification
1. T ≤ 100.
2. 0 ≤ x, y, v ≤ 10000.
Output "-1", if there's no possible answer.
Please use radian as unit.
0.222018 23.901887 121.909183
39.096669 110.210922 20.270030
138.355025 2028.716904 25.079551
-1
-1
//It is made by ljh2000
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int inf = (<<);
const double pi = acos(-);
const double eps = 1e-;
const double g = 9.80;
double X,Y,V,L,ans; inline int getint()
{
int w=,q=; char c=getchar();
while((c<'' || c>'') && c!='-') c=getchar(); if(c=='-') q=,c=getchar();
while (c>='' && c<='') w=w*+c-'', c=getchar(); return q ? -w : w;
} inline double cal(double o){
double vx,vy; vx=V*cos(o); vy=V*sin(o);
double tim=X/vx; double H=vy*tim-g*tim*tim/2.0;
return H;
} inline void three_div(){
double l=,r=pi/2.0,mm,mid;
while(r-l>eps) {
mm=l+(r-l)/; mid=mm+(r-l)/;
if(cal(mm)>cal(mid)) r=mid;
else l=mm;
}
L=l;
} inline void work(){
int T=getint(); double l,r,mid;
while(T--) {
cin>>X>>Y>>V; three_div();
if(cal(L)<Y) { printf("-1\n"); continue; }
if(fabs(cal(L)-Y)<=eps) { printf("%.6lf\n",L); continue; }
l=; r=L;
while(r-l>eps) {
mid=(l+r)*0.5;
if(cal(mid)<Y) l=mid,ans=mid;
else r=mid;
}
printf("%.6lf\n",ans);
}
} int main()
{
work();
return ;
}
HDU2298 Toxophily的更多相关文章
- HDU-2298 Toxophily (三分法入门系列)
题意: 意大利炮射出炮弹的速度为v,求在(0,0)击中(x,y)处的目标,发射炮弹的角度. 题解: 设f(α)表示角度为α时, f(α) = vsin(α) * t - 4.9 * t * t ① ...
- HDU 2298 Toxophily
题目: Description The recreation center of WHU ACM Team has indoor billiards, Ping Pang, chess and bri ...
- Toxophily
Problem Description The recreation center of WHU ACM Team has indoor billiards, Ping Pang, chess and ...
- HDU 2298 Toxophily(公式/三分+二分)
Toxophily Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 推公式hdu2298
(0,0)点到(x,y)以v射箭 问 最小的角度 不能射到 -1 x=v*cos(a)*t; y=v*sin(a)*t-0.5*g*t*t; 消去t; y=x*tan(a)-0.5*g*x*x/(v* ...
- HDU 2298 Toxophily 【二分+三分】
一个人站在(0,0)处射箭,箭的速度为v,问是否能够射到(x,y)处,并求最小角度. 首先需要判断在满足X=x的情况下最大高度hmax是否能够达到y,根据物理公式可得 h=vy*t-0.5*g*t*t ...
- HDU -2298 Toxophily(三分法)
这道题目,可以推出物理公式直接来做,但是如果推不出来就必须用程序的一种算法来实现了,物理公式只是适合这一个或者某个题,但是这种下面这种解决问题的方法确实解决了一类问题 ----三分法,大家可能都听说过 ...
- 【三分+精度问题】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)这个点,如果能,输出最小的射出 ...
随机推荐
- jboss eap 6.3 域(Domain)模式配置
jboss提供了二种运行模式:standalone(独立运行模式).domain(域模式),日常开发中,使用standalone模式足已:但生产部署时,一个app,往往是部署在jboss集群环境中的, ...
- IBM WebSphere MQ 7.5基本用法
一.下载7.5 Trial版本 http://www.ibm.com/developerworks/downloads/ws/wmq/ 这是下载网址,下载前先必须注册IBM ID,下载完成后一路Nex ...
- Logging的这点小事
真正做项目,才发觉Logging的好处和学问.自己胡搞的时候,常常使用System.out.println作为输出. 但实际的项目,尤其是library比较多的时候,好好配置好Logging,才能在后 ...
- 微软虚拟学院MVA 字幕获取方法
微软虚拟学院(MVA)上有一些不错的视频教程,但是,蛋疼的一点那就是视频要不就慢,要不就卡,总之当你的思维跟着视频深入的时候,duang~,卡一下,说不定就要重头开始,所幸的是提供了视频下载,下载速度 ...
- typedef 和define的区别
总结一下typedef和#define的区别 1.概念 #define 它在编译预处理时进行简单的替换,不作正确性检查.它是预处理指令. typedef 它在自己的作用域内给一个已经存在的类型一个别名 ...
- Nginx文件类型错误解析漏洞--攻击演练
今天看书看到其中提到的一个漏洞,那就是Nginx+PHP的服务器中,如果PHP的配置里 cgi.fix_pathinfo=1 那么就会产生一个漏洞.这个配置默认是1的,设为0会导致很多MVC框架(如T ...
- 求连续最大子序列积 - leetcode. 152 Maximum Product Subarray
题目链接:Maximum Product Subarray solutions同步在github 题目很简单,给一个数组,求一个连续的子数组,使得数组元素之积最大.这是求连续最大子序列和的加强版,我们 ...
- 深入理解 cocos2d-x 坐标系
首先对于初学的,带大家认识 cocos2d-x 中坐标系的几个概念,参考 http://blog.csdn.net/tskyfree/article/details/8292544.其他的往下看. 弄 ...
- C# 调用一个按钮的Click事件(利用反射)
最基本的调用方法 (1)button1.PerformClick();(2)button1_Click(null,null);(3)button_Click(null,new EventArgs()) ...
- C 语言学习的第 02 课:C 语言的开发环境
工欲善其事,必先利其器.不知道还是不是记得上一篇文章中说到的,计算机本身是一个数据输入及输出的设备.所以,为了将你大脑中的各种 idea 输入到电脑,且最终生成能够执行的程序,总是要预备点什么的. 通 ...