結果

問題 No.2058 Binary String
ユーザー tassei903tassei903
提出日時 2022-08-26 22:25:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 64,384 KB
最終ジャッジ日時 2024-04-22 00:31:05
合計ジャッジ時間 3,182 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
51,968 KB
testcase_01 AC 32 ms
51,840 KB
testcase_02 AC 52 ms
63,232 KB
testcase_03 AC 33 ms
52,224 KB
testcase_04 AC 33 ms
51,712 KB
testcase_05 AC 32 ms
51,968 KB
testcase_06 AC 44 ms
61,184 KB
testcase_07 AC 118 ms
63,744 KB
testcase_08 AC 53 ms
61,824 KB
testcase_09 AC 126 ms
63,616 KB
testcase_10 AC 77 ms
63,616 KB
testcase_11 AC 65 ms
62,592 KB
testcase_12 AC 90 ms
64,256 KB
testcase_13 AC 74 ms
63,872 KB
testcase_14 AC 68 ms
62,720 KB
testcase_15 AC 67 ms
62,592 KB
testcase_16 AC 66 ms
62,464 KB
testcase_17 AC 78 ms
63,616 KB
testcase_18 AC 46 ms
60,928 KB
testcase_19 AC 129 ms
63,616 KB
testcase_20 AC 119 ms
63,104 KB
testcase_21 AC 126 ms
64,384 KB
testcase_22 AC 121 ms
63,616 KB
testcase_23 AC 139 ms
64,000 KB
testcase_24 AC 128 ms
64,384 KB
testcase_25 AC 138 ms
63,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################[
n, k = na()
mod = 998244353
nn = n + 10
fact = [1] * nn
for i in range(nn - 1):
    fact[i + 1] = fact[i] * (i + 1) % mod
invfact = [1] * nn
invfact[nn - 1] = pow(fact[nn - 1], mod - 2, mod)
for i in range(nn - 1)[::-1]:
    invfact[i] = invfact[i + 1] * (i + 1) % mod
 
def binom(x, y):
    if x < 0 or y < 0 or x - y < 0:
        return 0
    return fact[x] * invfact[y] % mod * invfact[x - y] % mod

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