toI(s=readline()) = parse(Int,s) toVI(s=readline()) = toI.(split(s)) const MOD = 998244353 ⊕(x,y) = mod(x+y,MOD) ⊖(x,y) = mod(x-y,MOD) ⊗(x,y) = mod(x*y,MOD) ⊘(x,y) = x⊗invmod(y,MOD) ↑(x,y) = powermod(x,y,MOD) function main() n,p = toVI() solve(n,p) |> println end function solve(n,p) d,r = divrem(n,p) cnt = factmod(n) for d in 0:n÷p r = n - d*p cnt = cnt ⊖ combmod(n,r)⊗factmod(d*p)⊘factmod(p)↑d⊘factmod(d)⊗(factmod(p)-1)↑d end cnt end @generated function factmod(n) xs = zeros(Int,200001) xs[1] = 1 for i in 1:200000 xs[i+1] = xs[i]⊗i end return :($xs[n+1]) end function combmod(n,r) factmod(n)⊘(factmod(r)⊗factmod(n-r)) end main()