Editorial for DMPG '18 B2 - Mimi and Modulus


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.

Author: Kirito

For the first subtask, it suffices to iterate through all of the numbers 1, 2, \dots, N, and print the maximum residue mod M.

Time Complexity: \mathcal O(N)

For the second subtask, we can observe that the answer is upper bounded by N and M-1, as the result of any integer mod M will be less than M. Thus the answer is \min(N, M-1).

Time Complexity: \mathcal O(1)

Bonus: When is the answer N and when is it M-1?


Comments

There are no comments at the moment.