結果

問題 No.1967 Sugoroku Optimization
ユーザー googol_S0googol_S0
提出日時 2022-06-03 21:46:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 81,500 KB
実行使用メモリ 107,008 KB
最終ジャッジ日時 2023-10-21 01:46:23
合計ジャッジ時間 3,523 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
59,180 KB
testcase_01 AC 47 ms
59,180 KB
testcase_02 AC 49 ms
59,180 KB
testcase_03 AC 132 ms
107,004 KB
testcase_04 AC 53 ms
61,796 KB
testcase_05 AC 148 ms
103,872 KB
testcase_06 AC 159 ms
105,704 KB
testcase_07 AC 58 ms
63,912 KB
testcase_08 AC 135 ms
96,748 KB
testcase_09 AC 131 ms
91,436 KB
testcase_10 AC 94 ms
83,128 KB
testcase_11 AC 66 ms
68,044 KB
testcase_12 AC 129 ms
94,812 KB
testcase_13 AC 109 ms
85,076 KB
testcase_14 AC 65 ms
65,984 KB
testcase_15 AC 69 ms
68,044 KB
testcase_16 AC 66 ms
68,036 KB
testcase_17 AC 63 ms
65,944 KB
testcase_18 AC 54 ms
61,808 KB
testcase_19 AC 48 ms
59,200 KB
testcase_20 AC 131 ms
106,980 KB
testcase_21 AC 49 ms
59,200 KB
testcase_22 AC 127 ms
107,008 KB
testcase_23 AC 133 ms
94,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353
inv=[pow(i,mod-2,mod) for i in range(9999)]
N,K=map(int,input().split())
M=N-K
DP=[[0]*(N+1) for i in range(K+1)]
for i in range(K+1):
  DP[i][N]=1
for i in range(K-1,-1,-1):
  C=[0]*(N+2)
  for j in range(N+1):
    C[j+1]=C[j]+DP[i+1][j]
    if C[j+1]>=mod:
      C[j+1]-=mod
  for j in range(i,N):
    if j-i<M:
      DP[i][j]=(C[N+1]-C[j+1])*inv[N-j]%mod
    else:
      DP[i][j]=DP[i+1][j+1]
print(DP[0][0])
0