Editorial for MALD Contest 1 P2 - Scratch Cat and Examinations


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

The intended solution is to implement the ceiling division. Using double and built-in ceiling functions isn't accurate enough due to floating-point precision errors (unless you use 128-bit floating point). Division with two integers using the built-in division operator is floor division (e.g. 5/2 = 2). To implement ceiling division with integers, you can simply use \lceil \frac{x}{y} \rceil = \lfloor \frac{x+y-1}{y} \rfloor under the given constraints.

Complexity: \mathcal O(T)


Comments

There are no comments at the moment.