Skip to content

Commit dd7c150

Browse files
authored
Relativity
1 parent 9c8c6fd commit dd7c150

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

Code Chef/Relativity.cpp

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* Code Chef */
2+
/* Title - Relativity */
3+
/* Created By - Akash Modak */
4+
/* Date - 12/07/2021 */
5+
6+
// In Chefland, the speed of light is c m/s, and acceleration due to gravity is g m/s2.
7+
8+
// 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.
9+
10+
// Assume he jumps at zero velocity and at any time, his velocity (v) and depth of descent (H) are related as
11+
// v2=2⋅g⋅H.
12+
13+
// Input
14+
// The first line contains an integer T, the number of test cases. Then the test cases follow.
15+
// Each test case contains a single line of input, two integers g, c.
16+
// Output
17+
// 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.
18+
19+
// Sample Input
20+
// 3
21+
// 7 1400
22+
// 5 1000
23+
// 10 1000
24+
// Sample Output
25+
// 140000
26+
// 100000
27+
// 50000
28+
29+
30+
31+
#include<bits/stdc++.h>
32+
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
33+
#define F first
34+
#define S second
35+
#define pb push_back
36+
#define MP make_pair
37+
#define REP(i,a,b) for (int i = a; i <= b; i++)
38+
#define FLSH fflush(stdout)
39+
#define count_1(n) __builtin_popcountll(n)
40+
#define max(x,y) (x>y)?x:y
41+
#define min(x,y) (x<y)?x:y
42+
#define mid(s,e) (s+(e-s)/2)
43+
#define mini INT_MIN
44+
#define maxi INT_MAX
45+
46+
const int MOD = 1000000007;
47+
const int FMOD = 998244353;
48+
using namespace std;
49+
50+
typedef long long int ll;
51+
typedef vector<int> vi;
52+
typedef pair<int,int> pi;
53+
int main() {
54+
// your code goes here
55+
fast;
56+
int t;
57+
cin>>t;
58+
while(t--){
59+
int g,c;
60+
cin>>g>>c;
61+
ll velocity = pow(c,2);
62+
ll gravity = 2*g;
63+
cout<<(int)velocity/gravity<<"\n";
64+
}
65+
return 0;
66+
}

0 commit comments

Comments
 (0)