MINPIZZA - Editorial

PROBLEM LINK:

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

Author: Utkarsh Gupta
Tester: Harris Leung
Editorialist: Nishank Suresh

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

N friends each want to eat X slices of pizza. Each pizza has 4 slices. How many pizzas are needed?

EXPLANATION:

The total number of slices that need to be eaten is N\cdot X.

Buying K pizzas gives us 4K slices. We would like 4K \geq N\cdot X.

The smallest K for which this is true is K = \left\lceil \frac{N\cdot X}{4}\right\rceil, that is, the ceiling of \frac{N\cdot X}{4}.

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    n, x = map(int, input().split())
    print((n*x + 3)//4)