NPY and shot

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

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
 
题意:给你一个高度h,一个初始的速度v ;
   你选择一个角度扔使其最远;
思路:三分抛出的角度;
   显然函数成一段凸的抛物线形状;
   代码有注释;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define mk make_pair
#define eps 1e-7
#define bug(x) cout<<"bug"<<x<<endl;
const int N=1e6+,M=4e6+,inf=;
const ll INF=1e18+,mod=1e9+; /// 数组大小 double h,v;
double equ(double x)
{
double G=9.8,vx=v*cos(x/*pi),vy=v*sin(x/*pi);
double t=vy/G;// 到达最高点的时间
t+=sqrt(*G*h+vy*vy)/G; //到达顶端时间
// 2*G*h+vy*vy为到达最下端的速度的平方
return vx*t;
} double ternarySearch(double l,double r)
{
while(r-l>eps)
{
double L=(*l+r)/;
double R=(l+*r)/;
double ans1=equ(L);
double ans2=equ(R);
if(ans1<ans2)
l=L;
else
r=R;
}
return equ(l);
}
int main()
{
//cout<<sin(90.0/180*pi)<<endl;
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf",&h,&v);
double l=,r=90.0;
printf("%.2f\n",ternarySearch(l,r));
}
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) Tot ...

  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. BestCoder22 1003.NPY and shot 解题报告

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

  7. hdu 5142 NPY and FFT

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

  8. hdu 4717 The Moving Points(三分+计算几何)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 说明下为啥满足三分: 设y=f(x) (x>0)表示任意两个点的距离随时间x的增长,距离y ...

  9. Shot(三分)

    Shot Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

随机推荐

  1. 从jvm来看,scala中的@究竟是个什么鬼?@模式匹配符号(scala 词法分析 语法分析常用)

    从jvm来看,scala中的@究竟是个什么鬼? 我也是初步尝试来看jvm的类文件,又是初次来分析@,如不对的地方,请各位指正! 先看一下@ 是个什么? object TestScala { def m ...

  2. [LeetCode] questions conclustion_BFS, DFS

    BFS, DFS 的题目总结. Directed graph: Directed Graph Loop detection and if not have, path to print all pat ...

  3. loadrunner 接口性能脚本编写(Get请求和Post请求)

    前段时间接触了一下loadrunner的接口性能测试,然后尝试了一下手动编写脚本,毕竟录制这种东西,不是每次都能通的,而且录制下来的脚本,通常是有很多其他杂七杂八的请求夹杂在中间,没有达到真正的压测接 ...

  4. Java之构造器和构造方法的使用和意义

    我总是要把构造器和方法混淆,后来发现, 方法,实际上,是需要用于执行java代码的,而构造器, 构造器,,,是一个类的实例!!(我的理解,构造器是一个对象) 为什么呢? 类的实例,我们需要用类来创建对 ...

  5. try except else

    try except 语句还有一个可选的else子句,如果使用这个子句,那么必须放在所有的except子句之后.这个子句将在try子句没有发生任何异常的时候执行.例如: for arg in sys. ...

  6. ARM中的汇编指令

    Arm指令,32位的指令集,一共有16条的基本指令,每条指令都可以按条件执行, 指令都是32bit的,高四位是条件码[31:28], Thumb指令,16位的指令集,执行效率比arm指令集要低,但是节 ...

  7. 用js或css实现淡入淡出

    淡入淡出?你问我有什么用? 提升首页13格的东西,你居然不知道!! 好啦,不废话了,正文. 1 js 主要元素:fadeIn()   fadeOut() show hide 2 css 主要元素: o ...

  8. linux make命令安装详解

    对于GNU Make或许很多Windows开发的程序员并不是很了解,因为Windows中的很多集成开发环境(IDE)都帮我们做了这件事.但是作为一个专业从事 Linux嵌入式开发的程序员就必须要了解G ...

  9. Linux中Postfix虚拟用户及虚拟域(六)

    Postfix基于虚拟用户虚拟域的邮件架构 上图是一个几乎完整的邮件系统架构图,这里基于Mysql数据库进行用户认证,不管是Postfix.Dovecot.webmail都需要去Mysql数据库中进行 ...

  10. 在uboot中加入cmd_run命令,运行环境变量

    在学习uboot的过程中会经常烧录程序,每次都要敲一些下载指令.这样是不是很麻烦,有什么办法能快速的烧写呢.很简单,将需要敲击的指令编译到uboot中,以环境变量的形式存在.但是环境变量很好加,如何运 ...