結果

問題 No.2058 Binary String
ユーザー flygonflygon
提出日時 2022-09-19 16:57:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 105,856 KB
最終ジャッジ日時 2024-06-01 16:19:02
合計ジャッジ時間 4,058 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,840 KB
testcase_01 AC 39 ms
51,968 KB
testcase_02 AC 104 ms
105,592 KB
testcase_03 AC 38 ms
52,480 KB
testcase_04 AC 38 ms
51,968 KB
testcase_05 AC 37 ms
52,096 KB
testcase_06 AC 55 ms
63,232 KB
testcase_07 AC 175 ms
100,992 KB
testcase_08 AC 68 ms
68,480 KB
testcase_09 AC 182 ms
101,120 KB
testcase_10 AC 96 ms
77,696 KB
testcase_11 AC 74 ms
71,168 KB
testcase_12 AC 117 ms
87,552 KB
testcase_13 AC 101 ms
84,224 KB
testcase_14 AC 86 ms
73,984 KB
testcase_15 AC 84 ms
74,112 KB
testcase_16 AC 88 ms
75,648 KB
testcase_17 AC 99 ms
79,744 KB
testcase_18 AC 50 ms
61,696 KB
testcase_19 AC 183 ms
105,856 KB
testcase_20 AC 158 ms
95,872 KB
testcase_21 AC 179 ms
105,856 KB
testcase_22 AC 174 ms
105,728 KB
testcase_23 AC 192 ms
105,472 KB
testcase_24 AC 180 ms
105,600 KB
testcase_25 AC 192 ms
105,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
mod = 998244353

#nCk
def com(n,mod):
  fact = [1,1]
  factinv = [1,1]
  inv = [0,1]
  for i in range(2,n+1):
    fact.append((fact[-1]*i)%mod)
    inv.append((-inv[mod%i]*(mod//i))%mod)
    factinv.append((factinv[-1]*inv[-1])%mod)
  return fact, factinv

f,fi = com(n+10,mod)
def ncr(n,r):
  return f[n]*fi[r]%mod*fi[n-r]%mod
ans = 0
for i in range(n):
  tmp = ncr(n-1, i)
  ans += tmp * pow(i,k,mod)%mod
  ans %= mod
print(ans)
0