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 //题解: ...
随机推荐
- Linux入门之常用命令(13) crontab
为当前用户创建cron服务 1. 键入 crontab -e 编辑crontab服务文件 例如 文件内容如下: */2 * * * * /bin/sh /home/admin/jiaoben/bu ...
- unset与unlink
unset() -- 释放给定的变量 详见->http://www.kuqin.com/php5_doc/function.unset.html unlink() --删除文件 常用于用户 ...
- 使用java实现面向对象-File I/O
java.io.File类用于表示文件(目录) File类只用于表示文件(目录)的信息(名称.大小等),不能用于文件内容的访问 RandomAccessFile java提供的对文件内容的访问,既可以 ...
- 如何在maven pom.xml文件中设置Java编译器版本
今天遇到一个问题: 在Eclipse中用maven创建一个新的web项目,然后再用maven update一下,则JDK版本自动变为1.5. 通过查找资料,终于发现maven编译器插件(Maven C ...
- Vim的基本使用(二)
本文为原创文章,转载请标明出处 目录 11.可视模式 12.指定计数 13.重复命令 14.外部命令 15.命令行编辑 16.文件编辑 17.分割窗口 18.GUI命令 19.配置 20.Vim Ch ...
- vuejs2+axios设置
http://www.cnblogs.com/wisewrong/p/6402183.html 1 当前项目安装axios $ cnpm i axios --save-dev 2 import axi ...
- 自动化selenium开发
一.开发环境搭建 1.Firefox浏览器 1.1 下载firefix并安装. 1.2 Firefox中打开"开始菜单“ -> ”开发者“ -> ”获取更多工具“ -> 搜 ...
- Druid源码阅读之连接池
概述 Druid是阿里巴巴开源的一个数据库连接池 源码地址.下面简单分析一下连接池是怎么实现的 怎么开始阅读 如果使用过Druid连接池的都只要在Spring配置中配置jdbc的时候配置Driver是 ...
- Myeclipse 配置Tomcat 出现 “Value must be an existing directory”错误
今天上午配了一下本机上的Myeclipse的tomcat,因为我本机上有两个版本的myeclipse,一个是用来公司开发的,一个是自己玩的,本机上装了两个版本jdk和两个版本的tomcat.配置自己玩 ...
- C# 多线程、异步线程、线程池相关知识
/* 线程池ThreadPool类会在需要时增减池中线程的线程数,直到最大的线程数.池中的最大线程数是可配置的. 在双核CPU中,默认设置为1023个工作线程和1000个I/O线程.也可以指定在创建线 ...