From 982cac633ab5bedbb26d82c53906adde1cf698e8 Mon Sep 17 00:00:00 2001 From: subcrip Date: Mon, 1 Apr 2024 22:48:45 +0800 Subject: [PATCH] backup --- number/mll.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/number/mll.cc b/number/mll.cc index c0adf58..4ebe5e8 100644 --- a/number/mll.cc +++ b/number/mll.cc @@ -1,19 +1,14 @@ template 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); } + friend MLL operator+(const MLL& lhs, const MLL& rhs) { return mod(lhs.val + rhs.val, mdl); } + friend MLL operator-(const MLL& lhs, const MLL& rhs) { return mod(lhs.val - rhs.val, mdl); } + friend MLL operator*(const MLL& lhs, const MLL& rhs) { return mod(lhs.val * rhs.val, mdl); } + friend MLL operator/(const MLL& lhs, const MLL& rhs) { return mod(lhs.val * mod(inverse(rhs.val, mdl), mdl), 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; } }; - -template -ostream& operator<<(ostream& out, const MLL& num) { - return out << num.val; -}