/* author: Kite_kuma created: 2020.11.09 12:08:40 */ // #ifdef LOCAL // #define _GLIBCXX_DEBUG // #endif #include using namespace std; const int mod = 998244353; const int root = 3; unsigned int add(const unsigned int x, const unsigned int y) { return (x + y < mod) ? x + y : x + y - mod; } unsigned int sub(const unsigned int x, const unsigned int y) { return (x >= y) ? (x - y) : (mod - y + x); } unsigned int mul(const unsigned int x, const unsigned int y) { return (unsigned long long)x * y % mod; } unsigned int mod_pow(unsigned int x, unsigned int n) { unsigned int res = 1; while(n > 0) { if(n & 1) { res = mul(res, x); } x = mul(x, x); n >>= 1; } return res; } unsigned int inverse(const unsigned int x) { return mod_pow(x, mod - 2); } void ntt(vector &a, const bool rev = false) { unsigned int i, j, k, l, p, q, r, s; const unsigned int size = a.size(); if(size == 1) return; vector b(size); r = rev ? (mod - 1 - (mod - 1) / size) : (mod - 1) / size; s = mod_pow(root, r); vector kp(size / 2 + 1, 1); for(i = 0; i < size / 2; ++i) kp[i + 1] = mul(kp[i], s); for(i = 1, l = size / 2; i < size; i <<= 1, l >>= 1) { for(j = 0, r = 0; j < l; ++j, r += i) { for(k = 0, s = kp[i * j]; k < i; ++k) { p = a[k + r], q = a[k + r + size / 2]; b[k + 2 * r] = add(p, q); b[k + 2 * r + i] = mul(sub(p, q), s); } } swap(a, b); } if(rev) { s = inverse(size); for(i = 0; i < size; i++) { a[i] = mul(a[i], s); } } } vector convolute(const vector &a, const vector &b) { const int size = (int)a.size() + (int)b.size() - 1; int t = 1; while(t < size) { t <<= 1; } vector A(t, 0), B(t, 0); for(int i = 0; i < (int)a.size(); i++) { A[i] = a[i]; } for(int i = 0; i < (int)b.size(); i++) { B[i] = b[i]; } ntt(A), ntt(B); for(int i = 0; i < t; i++) { A[i] = mul(A[i], B[i]); } ntt(A, true); A.resize(size); return A; } #pragma region modint template struct ModInt { int x; ModInt() : x(0) {} ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(long long n) const { ModInt ret(1), mul(x); while(n > 0) { if(n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { long long t; is >> t; a = ModInt(t); return (is); } static int get_mod() { return mod; } }; using mint = ModInt; #pragma endregion int main() { int n; cin >> n; vector fac(n + 2); fac[0] = 1; for(int i = 0; i < n + 1; i++) { fac[i + 1] = fac[i] * (i + 1); } vector fx(n - 1); for(int i = 0; i < n - 1; i++) { fx[i] = ((mint)(i + 1) / fac[i]).x; } int k = n; vector res = {1}; while(k) { if(k & 1) { res = convolute(res, fx); if(res.size() >= n) res.resize(n - 1); } fx = convolute(fx, fx); if(fx.size() >= n) fx.resize(n - 1); k >>= 1; } res.resize(n - 1); cout << fac[n - 2] * res[n - 2] / mod_pow(n, n - 2) << endl; return 0; }