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. VirtualBox 虚拟磁盘的UUID修改

    个人测试环境,想构建一套Standby RAC环境,不想再重复去安装系统浪费时间,直接复制之前安装RAC前的一套VirtualBox的虚拟环境,不过打开时报错: 未能打开位于 Z:\Vbox\Stan ...

  2. Summary: difference between public, default, protected, and private key words

    According to Java Tutorial: Controlling Access to Members of a Class Access level modifiers determin ...

  3. QPixmap 显示大小

    size picSize(600,400); //将pixmap缩放成picSize大小然后保存在scaledPixmap中 按比例缩放: QPixmap scaledPixmap = pixmap. ...

  4. BinarySearch

    今天看代码,看到这么一段,开始没有看明白,记录下来备忘 foreach (FinancialReport r3 in addAorList)            {                i ...

  5. sql server删除重复数据,保留第一条

    SELECT * FROM EnterpriseDataTools.Enterprise.CompanyMainwhere CompanyNo in (select CompanyNo from En ...

  6. VS2010/MFC编程入门之三十八(状态栏的使用详解)

    上一节中鸡啄米讲了工具栏的创建.停靠与使用,本节来讲解状态栏的知识. 状态栏简介 状态栏相信大家在很多窗口中都能见到,它总是用来显示各种状态.状态栏实际上也是一个窗口,一般分为几个窗格,每个窗格分别用 ...

  7. C/S模型之UDP协议

    说明:利用UDP协议,创建一个服务器和一个客户端.两者间进行通信.由客户端进行输入内容,而服务器将接受的内容进行再一次返回,并显示在服务端. // UDP_Seversock.cpp : 定义控制台应 ...

  8. Python zip() 处理多于两个序列的参数, 存储结对的值

    zip() 可以接受多于两个的序列的参数.这时候所生成的结果元组中元素个数跟输入序列个数一样 >>> a = [1, 2, 3] >>> b = [10, 11, ...

  9. linux基础命令---bzip2

    bzip2 使用Burrows-Wheeler块排序文本压缩算法,将文件进行压缩,压缩比率比一般算法高一些.bzip2要求命令行标志附带一个文件名列表.每个文件都被自己的压缩版本替换,名称为“orig ...

  10. 20145310 Exp7 网络欺诈技术防范

    实验后回答问题 (1)通常在什么场景下容易受到DNS spoof攻击 局域网内最容易遭受攻击.通过DNS欺骗就可以轻松地将网址转到钓鱼网站.而我们平时最常用的局域网应该就是公共热点吧,特别是有的地方的 ...