1
0
Fork 0
This commit is contained in:
subcrip 2024-04-01 22:48:45 +08:00
parent 5a0b6bc880
commit 982cac633a
Signed by: subcrip
SSH Key Fingerprint: SHA256:dFPFi68d8C87YkFkEBU4TkcrYRySWpekRR1hbnDWUCw
1 changed files with 5 additions and 10 deletions

View File

@ -1,19 +1,14 @@
template <ll mdl> struct MLL { template <ll mdl> struct MLL {
ll val; ll val;
MLL(ll v = 0) : val(mod(v, mdl)) {} MLL(ll v = 0) : val(mod(v, mdl)) {}
MLL operator+(const MLL& rhs) { return mod(val + rhs.val, mdl); } friend MLL operator+(const MLL& lhs, const MLL& rhs) { return mod(lhs.val + rhs.val, mdl); }
MLL operator-(const MLL& rhs) { return mod(val - rhs.val, mdl); } friend MLL operator-(const MLL& lhs, const MLL& rhs) { return mod(lhs.val - rhs.val, mdl); }
MLL operator*(const MLL& rhs) { return mod(val * rhs.val, mdl); } friend MLL operator*(const MLL& lhs, const MLL& rhs) { return mod(lhs.val * rhs.val, mdl); }
MLL operator/(const MLL& rhs) { return mod(val * mod(inverse(rhs.val, mdl), mdl), mdl); } friend MLL operator/(const MLL& lhs, const MLL& rhs) { return mod(lhs.val * mod(inverse(rhs.val, mdl), mdl), mdl); }
MLL operator%(const MLL& rhs) { return mod(val - (*this / rhs).val, mdl); } friend MLL operator%(const MLL& lhs, const MLL& rhs) { return mod(lhs.val - (lhs / 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; } 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;
}