HDU 5144 NPY and shot(物理运动学+三分查找)
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
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.
If the height of NPY is 0,and he throws the shot at the 45° angle, he can throw farthest.
#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(物理运动学+三分查找)的更多相关文章
- hdu 5144 NPY and shot 物理+三分
NPY and shot Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Pro ...
- hdu 5144 NPY and shot
http://acm.hdu.edu.cn/showproblem.php?pid=5144 题意:给你初始的高度和速度,然后让你求出水平的最远距离. 思路:三分枚举角度,然后根据公式求出水平距离. ...
- HDU 5144 NPY and shot(三分法)
当时做这道题时一直想退出物理公式来,但是后来推到导数那一部分,由于数学不好,没有推出来那个关于Θ的最值,后来直接暴力了,很明显超时了,忘了三分法的应用,这道题又是典型的三分求最值,是个单峰曲线,下面是 ...
- hdu 5144(三分+物理)
NPY and shot Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- HDU 5144 三分
开始推导用公式求了好久(真的蠢),发现精度有点不够. 其实这种凸线上求点类的应该上三分法的,当作入门吧... /** @Date : 2017-09-23 21:15:57 * @FileName: ...
- HDU4355 三分查找
/* * 三分查找 */ #include<cstdio> #include<cmath> #define eps 1e-6 //typedef __int64 LL; i ...
- Gym 101246J Buoys(三分查找)
http://codeforces.com/gym/101246/problem/J 题意: 给定x轴上的n个点的坐标,按顺序从左到右给出,现在要使得每个点的间距相同,可以移动每个点的坐标,但是不能改 ...
- BestCoder22 1003.NPY and shot 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5144 题目意思:有个人抛物体,已知抛的速度和高度,问可以抛到的最远距离是多少.即水平距离. 做的时候是 ...
- hdu 5142 NPY and FFT
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5142 NPY and FFT Description A boy named NPY is learn ...
随机推荐
- verilog抓外部低频输入信号的上升沿和下降沿
版权申明:本文为博主窗户(Colin Cai)原创,欢迎转帖.如要转贴,必须注明原文网址 http://www.cnblogs.com/Colin-Cai/p/7220107.html 作者:窗户 Q ...
- Docker(九):Docker容器卷插件
1.Convoy 1.1 安装 [root@MediaServer tmp]# tar xvf convoy.tar.gz convoy/ convoy/convoy-pdata_tools conv ...
- MySQL数据库入门(建库和建表)--陈远波
建库.建表 1.建库 (1)SQL语句命令建库: Create database数据库名称 (该方法创建的数据库没有设置编码乱码) 1 2 3 4 5 -- 创建数据库时,设置数据库的编码方式 -- ...
- 《重新定义公司 - Google 是如何运营的》重点摘录
赋能:创意时代的组织原则 未来企业的成功之道,是聚集一批聪明的创意精英,营造合适的氛围和支持环境,充分发挥他们的创造力,快速感知用户需求,愉快地创造响应的产品和服务.未来组织的最重要功能,那就是赋 ...
- c# 了解c# 面向对象
C#是微软公司发布的一种面向对象的.运行于.NET Framework之上的高级程序设计语言.并定于在微软职业开发者论坛(PDC)上登台亮相.C#是微软公司研究员Anders Hejlsberg的最新 ...
- ProjectA: 多元非线性回归
https://www.youtube.com/watch?v=n9XycstdPYs&t=907s
- JMeter集合点
位置:添加--> 定时器-->Synchronizing Timer 注意:集合点放在所有操作之前. 假设线程组线程数设置的是50个,那么希望50个都准备好一块上,那么集合点中 ...
- thinkphp3.2.3使用ajax 的一些坑——使用AjaxReturn()后,直接返回null,模板文件不起作用
从接触thinkphp到今天,填完此坑,必有其他的坑有会冒出来.哎!这个填坑之路我想是没有尽头的了. 最近,需要使用ajax完成一些操作,一开始想Ajax简单啊,不过是一种提交数据的方式,不过是害苦了 ...
- windows安装ipython的困难重重
本机环境 系统: windows 10 64位 python版本:3.2.1 安装过程 安装ipython可以使用python的pip工具 pip install ipython 在使用pip前,我准 ...
- Ubuntu 16.04 升级 PHP 版本至 7.1
安装swoole扩展,怎么安装到7.0下去了,我本来编译的版本是7.19版本,但是没吃 升级步骤 $ sudo add-apt-repository ppa:ondrej/php $ sudo apt ...