Keplers Law codechef solution- Kepler’s Law states that the planets move around the sun in elliptical orbits with the sun at one focus. Kepler’s 3rd law is The Law of Periods, according to which: The square of the time period of the planet is directly proportional to the cube of the semimajor axis of its orbit. You are given the Time periods (T1,T2T1,T2) and Semimajor Axes (R1,R2R1,R2) of two planets orbiting the same star. Please determine if the Law of Periods is satisfied or not, i.e, if the constant of proportionality of both planets is the same. Print “Yes” (without quotes) if the law is satisfied, else print “No”.

Keplers Law solution codechef

 

Kepler’s Law states that the planets move around the sun in elliptical orbits with the sun at one focus. Kepler’s 3rd law is The Law of Periods, according to which:

  • The square of the time period of the planet is directly proportional to the cube of the semimajor axis of its orbit.

You are given the Time periods (T1,T2T1,T2) and Semimajor Axes (R1,R2R1,R2) of two planets orbiting the same star.

Please determine if the Law of Periods is satisfied or not, i.e, if the constant of proportionality of both planets is the same.

Print "Yes" (without quotes) if the law is satisfied, else print "No".

Input Format

  • The first line of input contains a single integer TT, denoting the number of test cases. The description of TT test cases follows.
  • Each test case consists a single line of input, containing four space-separated integers T1,T2,R1,R2T1,T2,R1,R2.

Output Format

For each test case, output a single line containing one string — "Yes" or "No" (without quotes); the answer to the problem.

You may print each character of the answer in uppercase or lowercase (for example, the strings “yEs”, “yes”, “Yes” and “YES” will all be treated as identical).

Constraints

  • 1T1041≤T≤104
  • 1T1,T2101≤T1,T2≤10
  • 1R1,R2101≤R1,R2≤10

Subtasks

Subtask 1(100 points): Original constraints

Sample Input 1 

3
1 1 1 1
1 2 3 4
1 8 2 8

Sample Output 1 

Yes
No
Yes

Explanation

  • Test Case 1112/13=12/1312/13=12/13
  • Test Case 2212/3322/4312/33≠22/43
  • Test Case 3312/23=82/83
  • For Solution

    Click Here!

Leave a Comment

Your email address will not be published.