diff --git a/library/math/mod_int.hpp b/library/math/mod_int.hpp index 81052c7d..a2fa8818 100644 --- a/library/math/mod_int.hpp +++ b/library/math/mod_int.hpp @@ -8,12 +8,5 @@ struct mint { mint operator+(mint b) { return x - mod + b.x; } mint operator-(mint b) { return x - b.x; } mint operator*(mint b) { return ll(x) * b.x % mod; } - mint operator/(mint b) { - int m = mod, u = 1, v = 0; - while (m) - u = exchange(v, u - b.x / m * v), - b.x = exchange(m, b.x % m); - assert(b.x == 1); - return *this * u; - } +#include "mod_int_division.hpp" }; diff --git a/library/math/mod_int_division.hpp b/library/math/mod_int_division.hpp new file mode 100644 index 00000000..a043afe4 --- /dev/null +++ b/library/math/mod_int_division.hpp @@ -0,0 +1,9 @@ +#pragma once +mint operator/(mint b) { + int m = mod, u = 1, v = 0; + while (m) + u = exchange(v, u - b.x / m * v), + b.x = exchange(m, b.x % m); + assert(b.x == 1); + return *this * u; +}