library icon indicating copy to clipboard operation
library copied to clipboard

montgomery64 does not work with m = 2 [bug]

Open dnx04 opened this issue 2 years ago • 0 comments

Describe the bug

montgomery64 struct of dynamic modulo failed in case the modulo is 2, while it must work when m is prime, and 2 is a prime. https://nyaannyaan.github.io/library/modint/modint-montgomery64.hpp

Additional context

I used your implementation of montgomery64 in this problem, but it got RE. https://atcoder.jp/contests/abc270/submissions/35398727

This test consists of cases when p = 2, and it fails in these cases, while ACL have quite the same implementation and worked.

dnx04 avatar Oct 04 '22 14:10 dnx04