結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー mkawa2mkawa2
提出日時 2022-11-25 21:29:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,022 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-04-10 02:40:51
合計ジャッジ時間 2,841 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,884 KB
testcase_01 AC 34 ms
53,424 KB
testcase_02 AC 34 ms
52,748 KB
testcase_03 AC 35 ms
52,888 KB
testcase_04 AC 34 ms
52,868 KB
testcase_05 AC 35 ms
52,204 KB
testcase_06 AC 34 ms
53,688 KB
testcase_07 AC 35 ms
53,532 KB
testcase_08 AC 35 ms
52,948 KB
testcase_09 AC 35 ms
53,108 KB
testcase_10 AC 35 ms
52,812 KB
testcase_11 AC 35 ms
52,752 KB
testcase_12 AC 35 ms
52,512 KB
testcase_13 AC 36 ms
52,560 KB
testcase_14 AC 34 ms
52,684 KB
testcase_15 AC 35 ms
54,352 KB
testcase_16 AC 36 ms
52,464 KB
testcase_17 AC 40 ms
59,436 KB
testcase_18 AC 41 ms
60,216 KB
testcase_19 AC 40 ms
60,788 KB
testcase_20 AC 34 ms
53,196 KB
testcase_21 AC 43 ms
60,740 KB
testcase_22 AC 36 ms
52,396 KB
testcase_23 AC 42 ms
61,496 KB
testcase_24 AC 36 ms
53,536 KB
testcase_25 AC 42 ms
62,124 KB
testcase_26 AC 37 ms
52,456 KB
testcase_27 AC 60 ms
77,440 KB
testcase_28 AC 36 ms
52,756 KB
testcase_29 AC 59 ms
76,932 KB
testcase_30 AC 36 ms
52,000 KB
testcase_31 AC 35 ms
52,876 KB
testcase_32 AC 33 ms
52,520 KB
testcase_33 AC 34 ms
52,728 KB
testcase_34 AC 34 ms
53,136 KB
testcase_35 AC 34 ms
53,352 KB
testcase_36 AC 34 ms
52,604 KB
testcase_37 AC 35 ms
53,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

def inv_arr(n):
    if n < 1: return []
    res = [-1, 1]
    for i in range(2, n+1):
        res.append(res[md%i]*(md-md//i)%md)
    return res

n = II()
m = II()

inv = inv_arr(m)
ans = pow(2, n, md)
c = 1
for r in range(m):
    ans -= c
    ans %= md
    c = c*(n-r)%md*inv[r+1]%md

print(ans)
0