PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: Pratiyush MIshra
Tester: Harris Leung
Editorialist: Nishank Suresh
DIFFICULTY:
TBD
PREREQUISITES:
None
PROBLEM:
Chef is on floor A and can run down X floors a minute. Chefina is on floor B and can run down Y floors a minute. Who reaches the ground floor faster?
EXPLANATION:
The time taken equals distance divided by speed.
So,
- Chef takes \frac{A}{X} minutes to reach the ground floor.
- Chefina takes \frac{B}{Y} minutes to reach the ground floor.
Compute these two values, and then compare them.
- If they are equal, the answer is “Both”.
- If \frac{A}{X} is smaller, the answer is “Chef”
- Otherwise, the answer is Chefina.
TIME COMPLEXITY
\mathcal{O}(1) per test case.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
a, b, x, y = map(int, input().split())
if a*y == b*x:
print('Both')
elif a*y > b*x:
print('Chefina')
else:
print('Chef')