/* -*- coding: utf-8 -*- * * 1967.cc: No.1967 Sugoroku Optimization - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 2000; const int MOD = 998244353; /* typedef */ template struct MI { int v; MI(): v() {} MI(int _v): v(_v % MOD) {} MI(long long _v): v(_v % MOD) {} MI operator+(const MI m) const { return MI(v + m.v); } MI operator-(const MI m) const { return MI(v + MOD - m.v); } MI operator*(const MI m) const { return MI((long long)v * m.v); } MI &operator+=(const MI m) { return (*this = *this + m); } MI &operator-=(const MI m) { return (*this = *this - m); } MI &operator*=(const MI m) { return (*this = *this * m); } MI pow(int n) const { // a^n % MOD MI pm = 1, a = *this; while (n > 0) { if (n & 1) pm *= a; a *= a; n >>= 1; } return pm; } MI inv() const { return pow(MOD - 2); } MI operator/(const MI m) const { return *this * m.inv(); } MI &operator/=(const MI m) { return (*this = *this / m); } }; typedef MI mi; /* global variables */ mi invs[MAX_N + 1]; mi dp[2][MAX_N + 1]; /* subroutines */ /* main */ int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 1; i <= n; i++) invs[i] = mi(i).inv(); dp[0][0] = 1; int cur = 0, nxt = 1; while (k--) { fill(dp[nxt], dp[nxt] + n + 1, 0); for (int i = 0; i < n; i++) dp[nxt][i + 1] += dp[cur][i] * invs[n - i]; dp[nxt][n] += dp[cur][n]; for (int i = 0; i < n; i++) dp[nxt][i + 1] += dp[nxt][i]; swap(cur, nxt); } printf("%d\n", dp[cur][n].v); return 0; }