可能有锅,谨慎使用!
class mint {
static const int mod=998244353;
public:
int num;
mint()=default;
mint(long long _num) : num(_num%mod) {}
mint &operator=(long long b) {return *this=mint(b);}
friend mint operator+(mint a,mint b) {return mint((a.num+b.num)%mod);}
friend mint &operator+=(mint &a,mint b) {return a=a+b;}
friend mint operator+(mint a,long long b) {return a+mint(b);}
friend mint &operator+=(mint &a,long long b) {return a=a+b;}
friend mint &operator++(mint &a) {return a+=1;}
friend mint operator++(mint &a,int) {mint copy(a);a+=1;return copy;}
friend mint operator-(mint a,mint b) {return mint(((a.num-b.num)%mod+mod)%mod);}
friend mint &operator-=(mint &a,mint b) {return a=a-b;}
friend mint operator-(mint a,long long b) {return a-mint(b);}
friend mint &operator-=(mint &a,long long b) {return a=a-b;}
friend mint &operator--(mint &a) {return a-=1;}
friend mint operator--(mint &a,int) {mint copy(a);a-=1;return copy;}
friend mint operator*(mint a,mint b) {return mint((long long)a.num*b.num%mod);}
friend mint &operator*=(mint &a,mint b) {return a=a*b;}
friend mint operator*(mint a,long long b) {return a*mint(b);}
friend mint &operator*=(mint &a,long long b) {return a=a*b;}
mint inv() {long long ans=1,a=num,b=mod-2;while (b) {if (b&1) ans=(long long)ans*a%mod;a=(long long)a*a%mod;b>>=1;}return mint(ans);}
friend mint operator/(mint a,mint b) {return a*b.inv();}
friend mint &operator/=(mint &a,mint b) {return a=a/b;}
friend mint operator/(mint a,long long b) {return a/mint(b);}
friend mint &operator/=(mint &a,long long b) {return a=a/b;}
};
标签:return,long,取模类,friend,operator,mint,模板,mod
From: https://www.cnblogs.com/mk-oi/p/mint.html