Measure Speed(https://www.codechef.com/CBST2021/problems/MESR)

Practice

Author: noob_tech
Tester: noob_tech
Editorialist: noob_tech

DIFFICULTY:

CAKEWALK, SIMPLE, EASY.

PREREQUISITES:

Math .

PROBLEM:

CodeMaster is driving his Car on a straight road at the speed of X Kilometers per Hours.The Speedometer of CodeMaster car has turned to be faulty but CodeMaster want to know the speed of his car.

CodeMaster is given two integers D and N.

D:- Distance in kilometers.

N:- Time in hour.

Help the CodeMaster to calculate the speed of the car X and Print the Speed of car.

NOTE-(Answer will always be integer).

QUICK EXPLANATION:

We will use the basic formula to calculate the speed of the car. i.e (Speed=Distance/Time).

EXPLANATION:

Here,we are given D(distance) and N(Time in hour) .Formula for finding the speed of the car is Distance/Time(D/N).
Consider D=100km and N=50 hour then speed of the car will be D/N i.e. 100/50= 2 km/hours. so ans will be 2 .

SOLUTIONS:

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n,d;
cin>>d>>n;
int k=d/n;
cout<<k<<endl;
}
return 0;
}

Tester's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n,d;
cin>>d>>n;
int k=d/n;
cout<<k<<endl;
}
return 0;
}

Editorialist's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n,d;
cin>>d>>n;
int k=d/n;
cout<<k<<endl;
}
return 0;
}