#include #include using namespace std; using ll = long long; #define REP(i,n) for(int i=0;i void chmin(T& a, T b) { a = min(a, b); } template void chmax(T& a, T b) { a = max(a, b); } #define PR(x) cerr << #x << "=" << x << endl using i128 = __int128_t; struct nCkmod { vector fanc; vector fancinv; long long mod; nCkmod(long long n, long long mod_ = 998244353): fanc(n + 1), fancinv(n + 1), mod(mod_) { fanc[0] = 1; fancinv[0] = 1; for(long long i = 1; i <= n; i++) { fanc[i] = (fanc[i - 1] * i) % mod; fancinv[i] = (fancinv[i - 1] * modinv(i)) % mod; } } long long modinv(long long a) { long long b = mod, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= mod; if (u < 0) u += mod; return u; } long long nck(int n, int k) { if(n < k) return 0; return fanc[n] * fancinv[k] % mod * fancinv[n - k] % mod; } }; int main() { int n; ll p; cin >> n >> p; nCkmod nck(200005); mint ans = nck.fanc[n]; REP(i, n / p + 1) { mint tmp = nck.fanc[n]; if(n >= p) { tmp *= nck.fancinv[n-p*i]; mint p_ = 1; p_ /= p; tmp *= p_.pow(i); tmp *= nck.fancinv[i]; } ans -= tmp; // cout << tmp.val() << endl; } cout << ans.val(); return 0; }