結果

問題 No.2058 Binary String
ユーザー shobonvipshobonvip
提出日時 2022-08-26 21:34:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 77,696 KB
最終ジャッジ日時 2024-04-21 23:33:35
合計ジャッジ時間 3,762 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
73,984 KB
testcase_01 AC 65 ms
73,984 KB
testcase_02 AC 77 ms
75,264 KB
testcase_03 AC 70 ms
74,112 KB
testcase_04 AC 66 ms
73,728 KB
testcase_05 AC 66 ms
73,856 KB
testcase_06 AC 74 ms
76,160 KB
testcase_07 AC 146 ms
76,288 KB
testcase_08 AC 86 ms
76,928 KB
testcase_09 AC 151 ms
76,032 KB
testcase_10 AC 101 ms
77,312 KB
testcase_11 AC 87 ms
76,800 KB
testcase_12 AC 114 ms
77,696 KB
testcase_13 AC 103 ms
77,312 KB
testcase_14 AC 95 ms
77,440 KB
testcase_15 AC 96 ms
77,184 KB
testcase_16 AC 95 ms
77,056 KB
testcase_17 AC 102 ms
77,184 KB
testcase_18 AC 75 ms
76,416 KB
testcase_19 AC 153 ms
76,288 KB
testcase_20 AC 139 ms
76,288 KB
testcase_21 AC 151 ms
75,904 KB
testcase_22 AC 145 ms
76,160 KB
testcase_23 AC 156 ms
76,288 KB
testcase_24 AC 150 ms
76,288 KB
testcase_25 AC 169 ms
76,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
N = 10**6 + 5
fact = [1]*(N+1)
factinv = [1]*(N+1)

for i in range(2, N+1):
	fact[i] = fact[i-1] * i % mod

factinv[-1] = pow(fact[-1], mod-2, mod)
for i in range(N-1, 1, -1):
	factinv[i] = factinv[i+1] * (i+1) % mod

def cmb(a, b):
	if (a < b) or (b < 0):
		return 0
	return fact[a] * factinv[b] % mod * factinv[a-b] % mod

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

ans = 0

for i in range(1, n):
	ans += cmb(n-1, i) * pow(i, k, mod)
	ans %= mod

print(ans)
0