DMOPC '14 Contest 8 P1 - Flare

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Stranded on an island, Tusk decides to launch a signalling flare, but forgets to angle it towards the water. As a result, it takes off perpendicular to the ground. Its height y in relation to its initial velocity v, Earth's gravitation g=-9.8\dfrac{m}{s^2} and time t given as:

\displaystyle y = vt + \frac{1}{2}gt^2

If Ange launches the flare from the ground where y=0 at time t=0, how long does Ange have to get out of the way before the flare comes burning down?

Input Specification

A single integer, v (1 \le v \le 10^{9}).

Output Specification

The time elapsed until the flare touches the ground, i.e. the value of t > 0 such that the expression evaluates to 0. Your answer will be considered correct if it is within an absolute or relative error of 10^{-6}.

Sample Input


Sample Output


Explanation of Output for Sample Input

Substituting in 2.040816 for t, we find that 10 \times 2.040816 + \dfrac{1}{2} \times (-9.8) \times (2.040816)^2 \approx 0.

Here is a displacement-time graph of the flare:


  • 5
    jackyliao123  commented on May 5, 2015, 8:55 p.m. edited

    I'm pretty sure that the gravity should be g=-9.8m/s^2 instead of g=-9.8m/s

    • 1
      Xyene  commented on May 5, 2015, 9:23 p.m.

      Indeed it should be, thanks.

  • 1
    sas5580  commented on May 5, 2015, 4:07 p.m.

    First paragraph says Tusk, second says Ange

    • 1
      FatalEagle  commented on May 5, 2015, 4:29 p.m.

      Ange launches the flare Tusk prepared.

      • -1
        BMP  commented on May 5, 2015, 11:39 p.m.

        rip sas5580