1
0
Fork 0
This commit is contained in:
subcrip 2024-03-23 23:32:27 +08:00
parent 5c236707f4
commit 89481b2877
Signed by: subcrip
SSH Key Fingerprint: SHA256:dFPFi68d8C87YkFkEBU4TkcrYRySWpekRR1hbnDWUCw
1 changed files with 19 additions and 0 deletions

19
number/mll.cc Normal file
View File

@ -0,0 +1,19 @@
template <ll mdl> struct MLL {
ll val;
MLL(ll v = 0) : val(mod(v, mdl)) {}
MLL operator+(const MLL& rhs) { return mod(val + rhs.val, mdl); }
MLL operator-(const MLL& rhs) { return mod(val - rhs.val, mdl); }
MLL operator*(const MLL& rhs) { return mod(val * rhs.val, mdl); }
MLL operator/(const MLL& rhs) { return mod(val * mod(inverse(rhs.val, mdl), mdl), mdl); }
MLL operator%(const MLL& rhs) { return mod(val - (*this / rhs).val, mdl); }
void operator+=(const MLL& rhs) { val = (*this + rhs).val; }
void operator-=(const MLL& rhs) { val = (*this - rhs).val; }
void operator*=(const MLL& rhs) { val = (*this * rhs).val; }
void operator/=(const MLL& rhs) { val = (*this / rhs).val; }
void operator%=(const MLL& rhs) { val = (*this % rhs).val; }
};
template <ll mdl>
ostream& operator<<(ostream& out, const MLL<mdl>& num) {
return out << num.val;
}