COW202 - Editorial

PROBLEM LINK:

Practice

Code-O-War

Author: Akash Kumar Bhagat
Tester: Sandeep Singh,Arnab Chanda
Editorialist: Akash Kumar Bhagat
Video Explanation: Youtube Link

DIFFICULTY:

Cakewalk

PREREQUISITES:

Basic Maths

PROBLEM:

We have a motor of X rpm and with the wheel of radius r cm. One has to calculate the distance travelled by car in t minutes.

EXPLANATION:

We have given the speed of the motor(X), the radius of the wheel(r) and time(t). With the help of the motor speed and the time, one can find the total number of rotation the wheel of the car rotated.

rotation=X*t

In one full rotation, the car can move a distance equal to the circumference of the wheel which is 2\pi r . Hence the total distance travelled by car will be,

distance=rotation*(2*pi*r)

As mentioned in the question, the answer should be on the floor value of the distance.

Do share your approach to the problem in the comment section :slight_smile: .

SOLUTIONS:

Python 3.7
for i in range(int(input())):
    x,r,t=map(int,input().split())
    pi=3.141
    print(int(2*pi*r*t*x))


CPP
#include <bits/stdc++.h>
#define ll long long int
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define scanarr(a,b,c) for( i=b;i<c;i++)cin>>a[i]
#define showarr(a,b,c) for( i=b;i<c;i++)cout<<a[i]<<' '
#define ln cout<<'\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define MAX 100005
using namespace std;
////////////////////////////////////////////////////////////////CODE STARTS HERE////////////////////////////////////////////////////////////////
 
void solve(){
	int n,i,j;
	int x,r,t;
	int sum;
	cin>>x>>r>>t;
 
	sum = 2* 3.141 *r *x*t;
 
	cout<<sum<<endl;
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif
	int t;
	cin>>t;
	while(t--)
		solve();
} 
1 Like