PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: kg_26, alpha_ashwin
Tester: raysh07
Editorialist: iceknight1093
DIFFICULTY:
TBD
PREREQUISITES:
None
PROBLEM:
An airline has X flights, each of which can carry 100 people.
How many more do they need to carry N people in total?
EXPLANATION:
Each flight can hold 100 people, so initially the airline can carry 100\cdot X people.
So, if 100\cdot X \geq N, no more aircraft are needed and the answer is 0.
Otherwise, N - 100\cdot X people are remaining.
Since 100 of them can be placed on a single flight, the minimum number of flights needed is
\left\lceil \frac{N-100\cdot X}{100} \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, n = map(int, input().split())
print(max(0, ceil((n - 100*x)/100)))