|
// -> x*u0*g % (u1*g) = (r1 - r0) (u0*g = m0, u1*g = m1) |
I think this should be:
x*u0*g % (u1*g) = (r1-r0) % (u1*g) (u0*g = m0, u1*g = m1)
For example, when (r0, r1) = (4, 0) and (m0, m1) = (5, 3), we have (x, g, u0, u1) = (-2, 1, 5, 3). So x*u0*g % (u1*g) is -1 (or 2 if we consider non-negative mod), but (r1-r0) is -4.
Anyway, the code itself seems correct.
ac-library/atcoder/math.hpp
Line 57 in c9838af
I think this should be:
For example, when
(r0, r1) = (4, 0)and(m0, m1) = (5, 3), we have(x, g, u0, u1) = (-2, 1, 5, 3). Sox*u0*g % (u1*g)is-1(or2if we consider non-negative mod), but(r1-r0)is-4.Anyway, the code itself seems correct.