Please subscribe to the official Codeforces channel in Telegram via the link ×

How do I find the integer division of A/B under some modulo?

Revision en1, by rhezo, 2016-12-11 00:23:26

I need to do integer division, that is floor of A/B. Eg: 5/2 = 2.

Now consider the modulo to be prime, multiplying A with inverse of B and taking modulo is wrong.

What I said above is true because , 6 * inverseOf(2) = 3. But 5 * inverseOf(2) is not equal to 2.

So how can I do this?


  Rev. Lang. By When Δ Comment
en1 English rhezo 2016-12-11 00:23:26 352 Initial revision (published)