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 //题解: ...
随机推荐
- java 读取properties文件总结
一.java读取properties文件总结 在java项目中,操作properties文件是经常要做的,因为很多的配置信息都会写在properties文件中,这里主要是总结使用getResource ...
- hadoop 基本命令
hdfs相关 1.查看HDFS文件目录 hadoop fs -ls / mapreduce相关 1.查看mapred job mapred job -list hadoop job -list Use ...
- MyBatis注解select in参数
/** * * @param ids '1,2,3' * @return */ @Select("select * from user_info where id in (${ids})& ...
- 一文为你详细讲解对象映射库【AutoMapper】所支持场景
前言 在AutoMapper未出世前,对象与对象之间的映射,我们只能通过手动为每个属性一一赋值,时间长了不仅是我们而且老外也觉得映射代码很无聊啊.这个时候老外的所写的强大映射库AutoMapper横空 ...
- php Socket通信
<?php error_reporting(0); $host = "0.0.0.0"; $port = 1082; $maxUser = 10; set_time_limi ...
- java中继承和组合的区别
子类继承父类,父类的所有属性和方法都可以被子类访问和调用.组合是指将已存在的类型作为一个新建类的成员变量类型,又叫"对象持有". 通过组合和继承,都可以实现系统功能的重用和代码的复 ...
- 学习如何看懂SQL Server执行计划(二)——函数计算篇
二.函数计算部分 --------------------标量聚合--------------------/* 标量聚合-主要在聚合函数操作中产生 计算标量:根据行中的现有值计算出一个新值 流聚合:在 ...
- Jquery滚动到页面底部自动Ajax加载图文列表,类似图片懒加载效果,带加载效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 第四章 MySQL高级查询(二)
第四章 MySQL高级查询(二) 一.EXISTS子查询 在执行create 或drop语句之前,可以使用exists语句判断该数据库对像是否存在,返回值是true或false.除此之外,exists ...
- Echarts数据可视化series-effectscatter特效散点图,开发全解+完美注释
全栈工程师开发手册 (作者:栾鹏) Echarts数据可视化开发代码注释全解 Echarts数据可视化开发参数配置全解 6大公共组件详解(点击进入): title详解. tooltip详解.toolb ...