DMOPC '14 Exam Time P2 - Physics Duel

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem types
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

Having mastered the secrets to the Art of Kinematics, you decide to show your power by challenging your physics teacher to a duel — a friendly one that is. The two of you are separated by a certain distance and right in the middle lies the holy book of SIN (more specifically, A Decade of SIN Plus Sixteen, which contains past contests and solutions to the University of Waterloo's Sir Isaac Newton Contest).

You believe you are worthy of bringing the book (which has a mass of 500.0g) home to solve problems from — but she wants you to suffer first. Using the force (yes, that force), she changes the velocity of the book several times. Since you are keeping your eyes on the clock, you know the exact time when she changes the velocity of the book and you also know the angle (as you always carry a protractor) and the duration of the time interval (you also have a stopwatch).

Your goal is to output the speed of the book when it hits the ground. Assume that the book is in free-fall on Earth after the last change in velocity is made and that it is accelerating towards the surface at g = 9.8 \frac m {s^2}. Assume that the book is unaffected by gravity while it is under the influence of the force.

Input Specification

The first line of input will contain one number n (1 \le n \le 10\,000) that represents the number of changes.

The next n lines will contain two integers and a real number, s (1 \le s \le 100), x (0 \le x \le 180) and t (1.0 \le t \le 1000.0).

s represents the speed of the book, in metres per second while x represents the direction, in degrees. More specifically, x is the angle between the book's direction and the east direction, clockwise.

t represents the time, in seconds, that the book travelled for. Note that t is given to one decimal place.

Output Specification

The only line of output is to contain the speed of the book when it hits the ground to the nearest integer.

Sample Input

10 30 2.0
5 120 1.5

Sample Output


Explanation for Sample Input

Our goal is to find the height the book reaches. Using the Law of Conservation of Energy we derive the following equation: v = \sqrt{2gh}, where h is the height the book reached, g is the acceleration due to gravity and v represents the speed of the book when it lands on the ground (the desired output).

To obtain the height the book reached, we need to obtain the vertical component of the book's velocity in each of the n lines.

Let h represent the height that the book reaches.
h = 2.0(10\sin 30^{\circ}) + 1.5(5\sin 120^{\circ})
h \approx 16.4952
Using v = \sqrt{2gh} ,
v \approx 17.9807
v \approx 18

The \sin function in your language may require the input to be in radians rather than degrees.
To convert from degrees (the input) to radians, simply multiply by \dfrac \pi {180}.


  • 2
    Kirito  commented on June 21, 2016, 10:46 a.m.

    This is 4th on the best submissions page, but is only 99/100. Why is this?

    • 2
      Xyene  commented on June 21, 2016, 12:31 p.m. edit 4

      This is a historical mistake on our part, thanks for letting us know! I've opened a ticket for it, with more detailed info there.

  • 2
    Jeffmagma  commented on April 14, 2016, 10:39 p.m.

    In the question, I think there's an extra close bracket after g=9.8m/s^2

  • -1
    msa789  commented on Jan. 13, 2015, 4:05 p.m.

    in input specification, the second s is x