You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for suggestion, but we don't have a plan to extend mod range to m < 2^32. As far as I know, at least 99% usage of modint is m < 2^31. TBH I don't came up any recent problems that requires 2^31 < m < 2^32. So, we prefer to prepare m < 2^31 modint rather than m < 2^32 modint with tricky technique.
The implementation of addition and subtraction in the ModInt structure does not seem to assume$2^{31}\le m\lt 2^{32}$ .
Suggested mitigation
this._v
andrhs._v
to 64-bit integer type.umod()
.umod()
, subtract the value ofumod()
from the sum._addcarry_u32
intsafe.h
:UIntAdd
umod()
, subtractumod()
from the sum.rhs._v
is greater thanself._v
, thenself._v - rhs._v + umod()
, otherwiseself._v - rhs._v
.Code
ac-library/atcoder/modint.hpp
Lines 74 to 83 in 6c88a70
ac-library/atcoder/modint.hpp
Lines 191 to 200 in 6c88a70
rust-lang-ja/ac-library-rs@ab2c3ed#diff-9c0db0574dc35afe73adabeaba95ec11f15af83bb2cf1d5d70b916b6da84e2eaR793-R812
Related Issue/PR
The text was updated successfully, but these errors were encountered: