This documentation is automatically generated by online-judge-tools/verification-helper
#include "math/mod-inv.hpp"#pragma once
#include "./base.hpp"
#include "./extgcd.hpp"
namespace matumoto {
constexpr ll modinv(ll n, ll mod) {
ll x = 0, y = 0;
extgcd(n, mod, x, y);
return (x % mod + mod) % mod;
}
} // namespace matumoto#line 2 "math/mod-inv.hpp"
#line 2 "math/base.hpp"
namespace matumoto {
using namespace std;
using ll = long long;
} // namespace matumoto
#line 2 "math/extgcd.hpp"
#line 4 "math/extgcd.hpp"
namespace matumoto {
constexpr ll extgcd(ll a, ll b, ll &x, ll &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
ll d = extgcd(b, a % b, y, x);
y = y - (a / b) * x;
return d;
}
} // namespace matumoto
#line 5 "math/mod-inv.hpp"
namespace matumoto {
constexpr ll modinv(ll n, ll mod) {
ll x = 0, y = 0;
extgcd(n, mod, x, y);
return (x % mod + mod) % mod;
}
} // namespace matumoto