刚刚随便写的,测试中,不建议投入使用
typedef long long ll;
template<int P>
struct Int {
unsigned x;
Int(ll _x = 0): x((_x + P) % P) {}
Int inv() const { return qpow(*this, P - 2); }
Int &operator += (const Int &t) { x = (x + t.x) % P; return *this; }
Int &operator -= (const Int &t) { x = (x + P - t.x) % P; return *this; }
Int &operator *= (const Int &t) { x = 1ll * x * t.x % P; return *this; }
Int &operator /= (const Int &t) { return (*this) *= t.inv(); }
friend Int qpow(Int t, ll k) {
Int res = 1;
while (k) {
if (k & 1) {
res *= t;
}
t *= t, k >>= 1;
}
return res;
}
friend Int operator + (Int a, const Int& b) { return a += b; }
friend Int operator - (Int a, const Int &b) { return a -= b; }
friend Int operator * (Int a, const Int &b) { return a *= b; }
friend Int operator / (Int a, const Int &b) { return a /= b; }
friend istream &operator >> (istream &is, Int &t) {
ll _t; is >> _t;
t = {_t};
return is;
}
friend ostream &operator << (ostream &os, const Int &t) { return os << t.x; }
};
const int P = 998244353;
typedef Int<P> itn;
const int N = 1e6 + 5;
int inv[N];
void get_inv() {
inv[1] = 1;
for (int i = 2; i < N; ++i) {
inv[i] = inv[P % i] * (P - P / i) % P;
}
}