Arun is working in an office which is N blocks away from his house. He wants to minimize the time it takes him to go from his house to the office.
He can either take the office cab or he can walk to the office.
Arun's velocity is V1 m/s when he is walking. The cab moves with velocity V2 m/s but whenever he calls for the cab, it always starts from the office, covers N blocks, collects Arun and goes back to the office.
The cab crosses a total distance of N meters when going from office to Arun's house and vice versa, whereas Arun covers a distance of 2–√∗N while walking.
Help Arun to find whether he should walk or take a cab to minimize the time.
Answers
Answered by
0
35335fhfg the
H
H
H
DC
The
Y
H
H
H
DC
The
Y
Answered by
0
Python:
Constrains:
1 <= V1, V2 <= 100
1 <= N <= 200
Program:
n,v1,v2=input().split(" ")
n,v1,v2=int(n),int(v1),int(v2)
tv1=(2**.5*n/v1)
tv2=(2*n/v2)
if(tv1>tv2):
print("Cab",end="")
else:
print("Walk",end="")
Input:
A single line containing n, v1 and v2 separated by space.
Example:
5 10 15
Output:
To print 'Walk' or 'Cab' accordingly.
Example:
Cab
Similar questions