Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
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:
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"
.
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).
Subtask 1(100 points): Original constraints
3
1 1 1 1
1 2 3 4
1 8 2 8
Yes
No
Yes
#include <stdio.h>
int main(void) {
int r;
scanf("%d",&r);
while(r--)
{
int d1,d2,r1,r2;
scanf("%d %d %d %d",&d1,&d2,&r1,&r2);
if(d1*d1*r2*r2*r2==d2*d2*r1*r1*r1)
{
printf("YES\n");
}
else
printf("NO\n");
}
return 0;
}
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
int t1,t2,r1,r2;
while(t--)
{
cin>>t1>>t2>>r1>>r2;
if(pow(t1,2)/pow(r1,3)==pow(t2,2)/pow(r2,3))
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
return 0;
}
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
for(int i=0;i<a;i++)
{
float t1=scan.nextInt();
float t2=scan.nextInt();
float r1=scan.nextInt();
float r2=scan.nextInt();
if (((t1 * t1) /( r1 * r1 * r1)) == ((t2 * t2 )/ (r2 * r2 * r2)))
{
System.out.println("Yes");
}
else
{
System.out.println("No");
}
}
}
}
# cook your dish here
t=int(input())
while(t!=0):
t1,t2,r1,r2=map(int,input().split())
ra1=t1**2/t2**2
ra2=r1**3/r2**3
if ra1==ra2:
print("Yes")
else:
print("NO")
t=t-1
In our experience, we suggest you solve this Keplers Law CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Keplers Law Problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Keplers Law CodeChef Solution.
I hope this Keplers Law CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More CodeChef Solutions >>
Olympics Ranking CodeChef Solution
Problem Difficulties CodeChef Solution
Chef and Bulb Invention CodeChef Solution