Relativity Codechef Solution

Relativity Codechef Solution

In Chefland, the speed of light is c m/sc m/s, and acceleration due to gravity is g m/s2g m/s2.

Find the smallest height (in meters) from which Chef should jump such that during his journey down only under the effect of gravity and independent of any air resistance, he achieves the speed of light and verifies Einstein’s theory of special relativity.

Assume he jumps at zero velocity and at any time, his velocity (vv) and depth of descent (HH) are related asv2=2⋅g⋅H.v2=2⋅g⋅H.

See Also : July Long Challenge 2021 Solutions Codechef

Input

  • The first line contains an integer TT, the number of test cases. Then the test cases follow.
  • Each test case contains a single line of input, two integers gg, cc.

Output

For each test case, output in a single line the answer to the problem. We can show that under the constraints, the answer is an integer.

Constraints

  • 1≤T≤5⋅1031≤T≤5⋅103
  • 1≤g≤101≤g≤10
  • 1000≤c≤30001000≤c≤3000
  • 2⋅g2⋅g divides c2c2.

Subtasks

Subtask #1 (100 points): Original constraints

Sample Input

3
7 1400
5 1000
10 1000

Sample Output

140000
100000
50000

Explanation

Test Case 11: For Chef to achieve the speed of light, the minimum height required is c22⋅gc22⋅g = 1400⋅1400141400⋅140014 = 140000140000 meters.

Test Case 33: For Chef to achieve the speed of light, the minimum height required is c22⋅gc22⋅g = 1000⋅1000201000⋅100020 = 5000050000 meters.

Solution

Program Python

# cook your dish here
t=int(input())
for i in range(t):
    g,c=map(int,input().split())
    res=((c*c)//(2*g))
    print(res)

July Long Challenge 2021 Solutions

Weekly Contest 247

Biweekly Contest 55

Leave a Comment