struct modint{
int x;
static int Mod;
constexpr static void setmod(int _){Mod=_;}
int qpow(int b,int p){
if(!p) return 1;
int d=qpow(b,p>>1);
if(p&1) return 1ll*d*d%Mod*b%Mod;
else return 1ll*d*d%Mod;
}
modint(int o=0){x=o;}
modint &operator=(int o){return x=o,*this;}
modint &operator+=(modint o){return x=x+o.x>=Mod?x+o.x-Mod:x+o.x,*this;}
modint &operator-=(modint o){return x=(x>=o.x?x-o.x:x-o.x+Mod),*this;}
modint &operator*=(modint o){return x=1ll*x*o.x%Mod,*this;}
modint &operator^=(modint o){return x=qpow(x,o.x),*this;}
modint &operator/=(modint o){return *this*=(o^=(Mod-2));}
friend modint operator+(modint a,modint b){return a+=b;}
friend modint operator-(modint a,modint b){return a-=b;}
friend modint operator*(modint a,modint b){return a*=b;}
friend modint operator/(modint a,modint b){return a/=b;}
friend modint operator^(modint a,modint b){return a^=b;}
friend bool operator==(modint a,modint b){return a.x==b.x;}
friend bool operator!=(modint a,modint b){return a.x!=b.x;}
bool operator<(const modint &b) const{return x<b.x;}
bool operator>(const modint &b) const{return x>b.x;}
bool operator<=(const modint &b) const{return x<b.x||x==b.x;}
bool operator>=(const modint &b) const{return x>b.x||x==b.x;}
bool operator!(){return !x;}
modint operator-(){return x?Mod-x:0;};
friend std::istream &operator>>(std::istream &is,modint &k) {
int val;
is>>val;
k=val;
return is;
}
friend std::ostream &operator<<(std::ostream &os,modint k){return os<<k.x;}
};
int modint::Mod=998244353;
//Remember to setmod()
标签:return,int,封装,operator,modint,friend,Mod
From: https://www.cnblogs.com/lemonniforever/p/18660642