Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
The fuel economy of a car is the distance which it can travel on one litre of fuel.
The base fuel economy (i.e, its fuel economy when there is only one person – the driver – in the car) of a certain car is M kilometres per litre. It was also observed that every extra passenger in the car decreases the fuel economy by 1 kilometre per litre.
P people want to take this car for a journey. They know that the car currently has V litres of fuel in its tank.
What is the maximum distance this car can travel under the given conditions, assuming that all P people always stay in the car and no refuelling can be done?
Note that among the P people is also a driver, i.e, there are exactly P people in the car.
For each test case, output a single line containing one integer – the maximum distance that the car can travel.
Input:
3
5 10 20
1 6 10
4 6 1
Output:
120
60
3
Test Case 1: There are 5 people in the car, and its base fuel economy is 10. Thus, its effective fuel economy is 10−4=6, since there are 4 people present other than the driver. There are 20 litres of fuel in the car, so the maximum distance that can be travelled is 6⋅20=120.
Test Case 2: The effective fuel economy is 6, and the maximum distance that can be travelled is 6⋅10=60.
Test Case 3: The effective fuel economy is 3, and the maximum distance that can be travelled is 3⋅1=3.
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int p,m,v;
cin>>p>>m>>v;
if(p==1)
cout<<m*v<<endl;
else cout<<(m-p+1)*v<<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
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int p=sc.nextInt();
int m=sc.nextInt();
int v=sc.nextInt();
if(p==1)System.out.println(m*v);
else System.out.println((m-p+1)*v);
}
}
}
# cook your dish here
for i in range(int(input())):
p,m,v=map(int,input().split())
o=p-1
if p==1:
print(m*v)
else:
print((m-o)*v)
In our experience, we suggest you solve this Car Range CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Car Range CodeChef Solution
I hope this Car Range 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 Coding Solutions.
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 Coding Solutions >>