結果
| 問題 |
No.2530 Yellow Cards
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-03 22:05:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 677 ms / 2,000 ms |
| コード長 | 1,081 bytes |
| コンパイル時間 | 414 ms |
| コンパイル使用メモリ | 82,308 KB |
| 実行使用メモリ | 82,796 KB |
| 最終ジャッジ日時 | 2024-09-25 20:28:29 |
| 合計ジャッジ時間 | 8,842 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
import sys
from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect
input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
return (g1[n] * g2[r] % mod) * g2[n-r] % mod
mod = 998244353
N = 2*10**5
g1 = [1]*(N+1)
g2 = [1]*(N+1)
inverse = [1]*(N+1)
for i in range( 2, N + 1 ):
g1[i]=( ( g1[i-1] * i ) % mod )
inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0
N,K = mi()
dp = [0] * (N+1)
dp[0] = 1
res = N
for _ in range(K):
ndp = [0] * (N+1)
for i in range(N+1):
if i!=0:
val = dp[i] * (i * inverse[N] % mod) % mod
res += val
res %= mod
ndp[i-1] += val
ndp[i-1] %= mod
if i!=N:
val = dp[i] * ((N-i) * inverse[N] % mod) % mod
ndp[i+1] += val
ndp[i+1] %= mod
dp = ndp
print(res)