Editorial for DMOPC '15 Contest 5 P1 - Gel Bananas


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.

Okabe and Kurisu will start an experiment together on day d if d-1 is divisible by both A and B. In other words, we want to find the number of common multiples of A and B between 0 and X-1, inclusive. We can find the lowest common multiple of A and B by using Euclid's GCD function, then divide to get our answer.

Time Complexity: \mathcal{O}(\log \max(A,B))


Comments

There are no comments at the moment.