NPY and shot

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1035    Accepted Submission(s): 428

 
Problem Description
NPY is going to have a PE test.One of the test subjects is throwing the shot.The height of NPY is H meters.He can throw the shot at the speed of v0 m/s and at the height of exactly H meters.He wonders if he throws the shot at the best angle,how far can he throw ?(The acceleration of gravity, g, is 9.8m/s2)
 
Input
The first line contains a integer T(T≤10000),which indicates the number of test cases.
The next T lines,each contains 2 integers H(0≤h≤10000m),which means the height of NPY,and v0(0≤v0≤10000m/s), which means the initial velocity.
 
Output
For each query,print a real number X that was rounded to 2 digits after decimal point in a separate line.X indicates the farthest distance he can throw.
 
Sample Input
2
0 1
1 2
Sample Output
0.10
0.99

Hint

If the height of NPY is 0,and he throws the shot at the 45° angle, he can throw farthest.

 
Source
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5144
分析:做三分做上瘾了,再来一道,物理数学得学好啊,不然有些题就算算法知道你也写不来啊,都是思维题,典型的质点运动学+三分查找!
下面给出AC代码:
 #include <bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
const double g=9.8;
double v,h;
const double eps=1e-;
double ans(double a)
{
double a1=v*v*sin(a)*sin(a);
double a2=*g*h;
a1=a1+a2;
a1=sqrt(a1);
a1=a1/g;
a1=a1+v*sin(a)/g;
a1=a1*v*cos(a);
return a1;
}
int main()
{
int T;
while(scanf("%d",&T)!=EOF)
{
while(T--)
{
scanf("%lf%lf",&h,&v);
double l=;
double r=pi/;
double midx,midy;
while (r-l>eps)
{
midx=(l+l+r)/;
midy=(l+r+r)/;
if(ans(midx)>ans(midy))
r=midy;
else l=midx;
}
printf("%.2f\n",ans(l));
}
}
return ;
}

HDU 5144 NPY and shot(物理运动学+三分查找)的更多相关文章

  1. hdu 5144 NPY and shot 物理+三分

    NPY and shot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  2. hdu 5144 NPY and shot

    http://acm.hdu.edu.cn/showproblem.php?pid=5144 题意:给你初始的高度和速度,然后让你求出水平的最远距离. 思路:三分枚举角度,然后根据公式求出水平距离. ...

  3. HDU 5144 NPY and shot(三分法)

    当时做这道题时一直想退出物理公式来,但是后来推到导数那一部分,由于数学不好,没有推出来那个关于Θ的最值,后来直接暴力了,很明显超时了,忘了三分法的应用,这道题又是典型的三分求最值,是个单峰曲线,下面是 ...

  4. hdu 5144(三分+物理)

    NPY and shot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  5. HDU 5144 三分

    开始推导用公式求了好久(真的蠢),发现精度有点不够. 其实这种凸线上求点类的应该上三分法的,当作入门吧... /** @Date : 2017-09-23 21:15:57 * @FileName: ...

  6. HDU4355 三分查找

    /*  * 三分查找  */ #include<cstdio> #include<cmath> #define eps 1e-6 //typedef __int64 LL; i ...

  7. Gym 101246J Buoys(三分查找)

    http://codeforces.com/gym/101246/problem/J 题意: 给定x轴上的n个点的坐标,按顺序从左到右给出,现在要使得每个点的间距相同,可以移动每个点的坐标,但是不能改 ...

  8. BestCoder22 1003.NPY and shot 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5144 题目意思:有个人抛物体,已知抛的速度和高度,问可以抛到的最远距离是多少.即水平距离. 做的时候是 ...

  9. hdu 5142 NPY and FFT

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5142 NPY and FFT Description A boy named NPY is learn ...

随机推荐

  1. WebUploader分片断点上传文件(二)

    写在前面: 这几天,有去研究一下WebUploader上传文件,前面的博客有记录下使用WebUploader简单上传文件的例子,今天就把分片断点上传的例子也记录下吧,在博客园中,也查看了一些资料,基本 ...

  2. JavaScript 中 闭包 的详解

    闭包是什么 在 JavaScript 中,闭包是一个让人很难弄懂的概念.ECMAScript 中给闭包的定义是:闭包,指的是词法表示包括不被计算的变量的函数,也就是说,函数可以使用函数之外定义的变量. ...

  3. SSH框架完全整合

    大三学期渐末,事情也挺多的,上周就开始着手整合SSH框架,到现在才真正的完成,过程中碰到了许多小问题(小问题大折腾,哭脸.jpg).本着善始善终的原则,最终把它给完成了. 本篇文章就在: win7 6 ...

  4. vue使用国际化

    转载请注明作者与出处 一:安装vue-i18n npm install vue-i18n --save 二:定义不同语言的json语言包 一般把它放到npm工程中的src目录下,因为这个目录是要进行编 ...

  5. 637. Average of Levels in Binary Tree

    Given a non-empty binary tree, return the average value of the nodes on each level in the form of an ...

  6. Visual simultaneous localization and mapping: a survey 论文解析(全)

    当激光或声纳等距离传感器被用来构建小的静态环境的二维地图时,SLAM的问题被认为是解决的.然而,对于动态,复杂和大规模的环境,使用视觉作为唯一的外部传感器,SLAM是一个活跃的研究领域. 第一部分是简 ...

  7. JS中数组的方法

    1. join() Array.join() 是 String.split() 的逆向操作 var arr = [1, 2, 3] arr.join()// "1,2,3" arr ...

  8. Java NIO (三) 通道(Channel)

    通道(Channel):由 java.nio.channels 包定义的,Channel 表示 IO 源与目标打开的连接.Channel 类似于传统的"流",只不过 Channel ...

  9. js必须掌握的基础

    好多人想要学习前端……自学或者培训那么我们在学习过程中到底需要掌握那些基础知识呢!下面分类了JS中必备的知识也是必须要了解学会的!看一看你是否已经将JS的基础知识都了如指掌了呢? 事件: onmous ...

  10. mybatis的知识点

    mybatis核心配置文件的配置 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE conf ...