Rosetta Problems

(Ax+B) mod M(Ax + B) \bmod M の最小値

N,M,A,BN, M, A, B が与えられ、0≤x<N0 \leq x < N における (Ax+B) mod M(Ax + B) \bmod M の最小値を求める。

関連リンク