VM7WC '15 #3 Bronze - M's Theorem!

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

In M's class, Andrew is currently learning the chain rule (see Melanie's Theorem) for adding vectors. He's tried adding vectors tip-to-tail, but since he has no skill in math he's unable to do so. Your job is to create a program to add a series of vectors to help Andrew solve his physics problems.

You will be given vectors in the form of a magnitude and angle. Andrew's physics problems use angles in the standard unit circle convention (i.e. starting from the right hand side going counterclockwise), and all angles are positive. You may assume that the tail of the first vector is at the origin.

Input Specification

The first line of input, N (1 \le N \le 100), will consist of the number of vectors to be added.

The next N lines will consist of a magnitude, R, and an angle in degrees, D. You should note that angles may be greater than 360 degrees.

Output Specification

Your program should output the resultant vector's magnitude and angle, with a single space in between them. Both values should be rounded to the nearest whole number. Your angle must be greater or equal to 0 and less than 360.

Sample Input

3
4 100
2 10
5 330

Sample Output

6 18

Comments


  • -2
    bobhob314  commented on Jan. 23, 2015, 1:32 a.m.

    There seems to be a lack of information on Melanie's theorem on the web. Notably, its Wikipedia page has been deleted. Could some information be provided on its use?

    Thanks,

    hob


    • -1
      FatalEagle  commented on Jan. 23, 2015, 1:46 a.m.

      It is irrelevant to the problem.


      • -1
        bobhob314  commented on Jan. 23, 2015, 1:57 a.m.

        Does this problem require some next level vector graphing parabola humdinger in the hood?


        • 0
          FatalEagle  commented on Jan. 23, 2015, 3:07 a.m.

          It requires (relatively) elementary mathematical knowledge for a contest programmer. I guess in Ontario you would learn this in grade 10 but it's really not as difficult as you think.


          • 0
            bobhob314  commented on Jan. 23, 2015, 5:14 p.m. edited

            Oh xD Niceme.me


            • 1
              thorthugnasty  commented on Jan. 23, 2015, 10:30 p.m.

              Melanie's theorem was removed due to lack of sufficient sourcing. However, I assure you that it remains the best way to add relative vectors. In case you haven't heard of it, it is also known as the chain rule.