题目:

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.
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.
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.
Technical Specification

1. T ≤ 100.
2. 0 ≤ x, y, v ≤ 10000.

Output
For each test 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.

Sample Input
3
0.222018 23.901887 121.909183
39.096669 110.210922 20.270030
138.355025 2028.716904 25.079551
Sample Output1.561582-1-1

题意:一个果子在平面坐标的(x,y)处,你人在(0,0)处丢出一个速度为v的石子,问:使得石子能扔到果子的扔石子最小角度为多少(初速度与x轴的夹角)

思路:高中物理推出公式:y = v*sinθ*t -1/2*g*t*t,t = x / v*cosθ. 根据此公式三分求得可以达到果子的高度及以上高度的最大角度,然后在二分求得满足要求的最小角度

代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int maxn = 100;
int T;
double x,y,v;
double l,r;/*y = v*sinθ*t - 1/2*g*t*t,t = x / v*cosθ。
*/double cal(double th)//th为的弧度
{double t=x/(v*cos(th));return v*sin(th)*t-4.9*t*t;
}int main()
{scanf("%d",&T);while(T--){scanf("%lf%lf%lf",&x,&y,&v);l=0,r=PI/2;if(x==0){if(v*v/19.6>=y)//v^2=2gyprintf("%.6f",PI/2);elseprintf("-1\n");continue;}for(int i=0;i<=100;i++)  {double mid,midmid;mid=(l+r)/2.0;midmid=(mid+r)/2.0;if(cal(mid)>cal(midmid))r=midmid;elsel=mid;}if(cal(r)<y){printf("-1\n");continue;}l=0;for(int i=0;i<=100;i++){double mid=(l+r)/2.0;if(cal(mid)>y)r=mid;elsel=mid;}printf("%.6f\n",r);}return 0;
}

CSU-ACM2017暑期训练5-三分 D - Toxophily HDU - 2298相关推荐

  1. Potato的暑期训练day#1题解 ——毒瘤构造

    Potato的暑期训练day#1 --毒瘤构造 题目链接: A.https://vjudge.net/problem/HDU-1214 B.https://vjudge.net/problem/Cod ...

  2. 暑期训练日志----2018.8.26

    训练第28天. 暑期训练最后一天,结束了... 看了看昨天下午网络赛的题,感觉自己也就能出一个...还是学的太少,新学期开始要加油,每天至少2个小时搞ACM 这个暑假收获很多,跟队友的配合比之前更有默 ...

  3. 暑期训练日志----2018.8.3

    训练第五天. 效率比昨天快了不少,但还是所有人中进度最慢的. 成功将排列与组合.以及延迟认可算法搞清楚了,而且之前欠的卡特兰数列和第一类.第二类斯特林数也补上了,组合数学的内容之差母函数.莫比乌斯反演 ...

  4. HRBU 2021年暑期训练阶段二Day3

    目录 A - Shuffle'm Up 题目链接: 题意: 做法: B - Prime Path 题目链接: 题意: 做法: C - Function Run Fun 题目链接: 题意: 做法: D ...

  5. HRBU 2021年暑期训练阶段三Day1

    目录 A - Similar Strings 题目链接: 题意: 做法: B - card card card 题目链接: 题意: 做法: C - String 题目链接: 题意: 做法: D - C ...

  6. Noip2019暑期训练2 反思

    经过两次测试,通过深刻的反思,我主要发现了以下易犯错误: 1.做题目时过于追求速度,导致好几处代码都出现手误打错的现象!而且,千万不要图快.图方便就复制粘贴,非常容易出错!(例如T3-party中直接 ...

  7. 牛客2021暑期训练1-A-Alice and Bob

    牛客2021暑期训练1-A-Alice and Bob 题目链接 题意 给定两堆石子n,m(1<=n,m<=5e3),Alice先手,对任意一堆取k(k>0)个,另一堆取s*k(s& ...

  8. csu 1548: Design road (三分)

    题意:需要从(0,0) 点 到(x,y) 修一段路 其中有n条和y轴平行的河 修路的单位成本c1 修桥的单位成本c2 问最小总成本为多少 思路:把所有河合并 再三分桥的长度 求出最小成本 #inclu ...

  9. 暑期训练日志----2018.8.25

    训练第27天. 临近训练结束,身体终于垮了...上午还强撑了一会看了看之前个人赛的题,下午直接回宿舍躺着了...错过了教练过来宣布的很多事情,头大... 2018.8.25

最新文章

  1. vmware vsphere 虚拟化之安装esxi
  2. 韩春雨,时隔六年再发高分论文
  3. 第一篇随笔,通常都是内容空洞的。
  4. 认清JavaScript和JAVA全局变量和局部变量的作用域
  5. Linux内核系统调用处理过程
  6. 字典树从第i个构造HDU2846
  7. springboot项目中jdk版本的问题
  8. 程序员能靠技术渡过中年危机吗?
  9. P3919 【模板】可持久化数组(可持久化线段树/平衡树)(入门第一题)
  10. Codeforces Round #666 (Div. 2)C - Multiples of Length(错位相减)
  11. 创建图片mat_Python骚操作,让图片人物动起来!
  12. 优先队列练习(又是我大钟神)
  13. 记录数据库面试题及答案21~41
  14. 联想台式计算机 不启动u盘,联想电脑没有u盘启动项怎么回事_联想电脑bios没有U盘启动项如何处理-系统城...
  15. android youtube webview,在Android WebView中播放Youtube HTML5嵌入式视频
  16. C语言基础练习-输入球体半径,计算球体表面积和体积
  17. 怎样改计算机密码忘了怎么办,电脑设置的密码忘了怎么办
  18. Java版的TxT转换器下载_TXT转MP3格式转换器
  19. 2021年3月8日:MyBatis框架学习笔记02:利用MyBatis实现CRUD操作
  20. 1094 谷歌的招聘(JAVA)

热门文章

  1. python搭建博客系统_Mezzanine 搭建 BLOG 系统
  2. 阅读《人类简史》-- 1.认知革命
  3. 技术展示:综合布线系统的设计分析
  4. Dynamics 365 CRM 中 打开自定义页面 Xrm.Navigation.navigateTo Open Web Resource
  5. 薇娅,李佳琦都点赞的淘宝双11直播系统,是如何打造的?
  6. 远程 PC 访问软件
  7. vba excel 开发游戏_自动化神器—VBA
  8. 【Dos】常见的Dos攻击
  9. R语言用igraph绘制网络图可视化
  10. stm32之备份寄存器(BKP)应用(侵入检测中断)