Relativity | RELATIVE | CODECHEF JULY CHALLENGE Solution

Codechef

View problem on codechef

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.

For the work from home Internship Programs : Click here to apply now

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

#include <iostream>
#include <bits/stdc++.h>

using namespace std;
#define ll long long int

int main(){
    ll test;
    cin>>test;
    while(test--){
        ll c,g;
    cin>>g>>c;
    c=c*c;
    g*=2;
    cout<<c/g<<endl;
    }
}

Read more post Here

Leave a Comment

Your email address will not be published. Required fields are marked *

x