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. SQL Expression Language Tutorial 学习笔记一

    http://docs.sqlalchemy.org/en/latest/core/tutorial.html Google 翻译了一下 SQLAlchemy Expression Language, ...

  2. 手把手教你,C#.Net如何用Log4net把错误日志写入到SQLite数据库中

    在项目中,我们往往会有把错误日志记录下来的习惯,这样有利于当网站发布后,能第一时间找到错误的所在地,以及错误的原因,以便于我们第一时间纠错.往往我们会把错误日志直接写到txt文本中,虽然操作简单,但是 ...

  3. http 之 HTTP_X_FORWARDED_FOR

    原文   http://www.imququ.com/post/x-forwarded-for-header-in-http.html 主题 HTTP Nginx 我一直认为,对于从事 Web 前端开 ...

  4. 2:3 Action的配置

    < 一 作用> 一:封装工作单元(相当于是控制层,封装出modelAndView) 二:定义name属性接受前台传过来的数据,再定义message属性,用于存放返回前台页面展示的数 据,实 ...

  5. yii2关联查询两组一对一

    public function getMember1(){        return $this->hasOne(Member::className(), ['wechat_id' => ...

  6. GBDT理论知识总结

    一. GBDT的经典paper:<Greedy Function Approximation:A Gradient Boosting Machine> Abstract Function ...

  7. Ignite集群管理——基于静态IP的节点发现

    Ignite作为分布式内存,集群管理必不可少,Ignite支持基于组播,静态IP,Zookeeper,JDBC等方式发现节点,本文主要介绍基于静态IP的节点发现. 两个最重要的TCP通信设置类: 1. ...

  8. 在windows上构建LLVM 7.0.1

    关于在windows上构建LLVM,网上有不少文章,但都是互相抄来的,写作时极不认真,不是少这个,就是少那个,没有一篇是可以完整照着做下来的,实在气人. 本文的安装和配置过程,我亲自操作过好几遍,不惜 ...

  9. APP获取证书签名指纹

    Android: public static String getSignatureSHA1(Context context) { String sign = null; try { // 通过包管理 ...

  10. Python Web学习笔记之进程与线程

    要了解二者的区别与联系,首先得对进程与线程有一个宏观上的了解. 进程,是并发执行的程序在执行过程中分配和管理资源的基本单位,是一个动态概念,竟争计算机系统资源的基本单位.每一个进程都有一个自己的地址空 ...