Hdoj 5144 NPY and shot simple physics

Source: Internet
Author: User



Three-point angle ....


NPY and shotTime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 236 Accepted Submission (s): 87


Problem Descriptionnpy is going to has 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/s^2$)
Inputthe first line contains a integer $T (T \leq 10000) $,which indicates the number of test cases.
The next T lines,each contains 2 integers $H (0 \leq H \leq 10000m) $,which means the height of Npy,and $v _0 (0 \leq v_0 \leq 10000M/S) $, which means the initial velocity.
Outputfor each query,print a real number X is rounded to 2 digits after the decimal point and a separate line. X indicates the farthest distance he can throw.
Sample Input
20 11 2

Sample Output
0.100.99HintIf The height of NPY is 0,and he throws the shot at the 45°angle, he can throw farthest.

Sourcebestcoder Round #22


/* ***********************************************author:ckbosscreated time:2014 December 13 Saturday 23:27 32 seconds file Name : c.cpp************************************************ * * #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <cstdlib> #include <vector># Include <queue> #include <set> #include <map> #include <cmath>using namespace Std;const double Eps=1e-6;const Double g=9.8;double h,v;double Distan (double degree) {double Vx=v*sin (degree);d ouble vy=v*cos (degree); Double time = (Vx+sqrt (vx*vx+2*g*h))/G;return Time*vy;}    int main () {//freopen ("In.txt", "R", stdin); Freopen ("OUT.txt", "w", stdout), int t_t;scanf ("%d", &t_t), while (t_t--) {scanf ("%lf%lf", &h,&v);d ouble Low=0.,high=90.; Double Mid1,mid2,ans=0;while (Fabs (high-low) >=eps) {mid1= (Low*2+high)/3.; Mid2= (low+high*2)/3.; Double Len1=distan (MID1);d ouble Len2=distan (MID2); Ans=max (Ans,max (LEN1,LEN2)); if (len2+ePS&GT;LEN1) Low=mid1;else High=mid2;}    printf ("%.2lf\n", ans);} return 0;}



Hdoj 5144 NPY and shot simple physics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.