BestCoder22 1003.NPY and shot Problem solving report

Source: Internet
Author: User
Tags cmath

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5144

The title means: there is a person throwing objects, known to throw the speed and height, ask what the farthest distance can be thrown. That is, the horizontal distance.

The time to do is to copy the formula, incredibly past, lucky lucky ...

  

1#include <iostream>2#include <cstdio>3#include <cmath>4#include <cstring>5#include <algorithm>6 using namespacestd;7 8 Const Doubleg =9.8;9 Ten intMain () One { A     intT; -     Doubleh, v; -      while(SCANF ("%d", &t)! =EOF) the     { -          while(t--) -         { -scanf"%LF%LF", &h, &v); +             DoubleTMP = sqrt (v*v + 1ll *2* g *h); -             Doublet = tmp/G; +             DoubleAns = t *v; Aprintf"%.2lf\n", ans); at         } -     } -     return 0; -}
View Code

Udong do more formal, is done with three points, and floating-point precision control, it is worth learning ^_^ (without his permission to steal his copyright, should not blame me ...) )

  

1#include <algorithm>2#include <cstdio>3#include <cstdlib>4#include <cmath>5#include <iostream>6#include <map>7#include <numeric>8#include <vector>9 Ten using namespacestd; One  A Const DoubleEPS = 1e-8; - Const DoublePI = ACOs (-1.0); - Const DoubleG =9.8; the  - inth, v; -  - DoubleFDoubleang) + { -   DoubleHV = cos (ANG) *v; +   Doublevv = sin (ANG) *v; A   DoubleT1 = vv/G; at   Doublet2 = sqrt (2* (vv*t1-g*t1*t1/2.0+H)/G); -   returnhv* (t1+T2); - } -  - intMain () - { in   intKase; -scanf"%d", &Kase); to    while(kase--) { +scanf"%d%d", &h, &v); -     DoubleL =0.0, R = pi/2; the      while(L < REPS) { *       DoubleD = (r-l)/3.0; $       DoubleLL = L +D;Panax Notoginseng       DoubleRR = RD; -       if(F (LL) <F (RR)) theL =ll; +       Else AR =RR; the     } +printf"%.2f\n", F (L)); -   } $   return 0; $}

  

BestCoder22 1003.NPY and shot Problem solving report

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.