现在的位置: 首页 > 综合 > 正文

HDU 5144 NPY and shot 物理题,抛球距离最远

2018年01月19日 ⁄ 综合 ⁄ 共 1067字 ⁄ 字号 评论关闭

NPY and shot

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

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(T10000),which
indicates the number of test cases.
The next T lines,each contains 2 integers H(0h10000m),which
means the height of NPY,and v0(0v010000m/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.
/*
HDU 5144 物理题,抛球距离最远 
*/
#include<iostream>
#include<stdio.h>
#include<math.h>
using  namespace std;
#define G 9.8
int main()
{
	int t,h,v;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d",&h,&v);		
		printf("%.2lf\n",1.0*v*(sqrt(v*v+2*G*h))/G);
	}
	return 0;
}

抱歉!评论已关闭.