MOZZ - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: iceknight1093
Tester: satyam_343
Editorialist: iceknight1093

DIFFICULTY:

752

PREREQUISITES:

None

PROBLEM:

Chef receives 30 rupees for each mozzarella stick he eats past the X-th one.
You know that Chef received R rupees, and each plate contains Y sticks.

Find the maximum number of plates Chef could’ve ordered.

EXPLANATION:

Chef received 30 rupees for each extra stick he ate.
Since he received R rupees in total, the number of extra sticks he ate is \frac{R}{30}.

This means the total number of sticks he ate is X + \frac{R}{30}.
Let this number be \text{tot}.

Each plate contains Y sticks.
So, Chef needs to order enough plates to have Y sticks in total.
The number of plates needed to do this is exactly

\left\lceil \frac{\text{tot}}{Y} \right\rceil

where \left\lceil \ \ \right\rceil denotes the ceiling function.

TIME COMPLEXITY

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (Python)
from math import ceil
for _ in range(int(input())):
    x, y, r = map(int, input().split())
    eaten = x + r//30
    print(int(ceil(eaten / y)))