結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー kyskys
提出日時 2022-11-25 21:27:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 1,113 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 75,588 KB
最終ジャッジ日時 2024-04-10 02:37:34
合計ジャッジ時間 2,982 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,496 KB
testcase_01 AC 36 ms
53,744 KB
testcase_02 AC 37 ms
53,008 KB
testcase_03 AC 36 ms
53,068 KB
testcase_04 AC 37 ms
52,768 KB
testcase_05 AC 38 ms
53,760 KB
testcase_06 AC 37 ms
52,340 KB
testcase_07 AC 36 ms
53,444 KB
testcase_08 AC 37 ms
52,788 KB
testcase_09 AC 38 ms
53,848 KB
testcase_10 AC 37 ms
52,404 KB
testcase_11 AC 37 ms
53,936 KB
testcase_12 AC 38 ms
54,056 KB
testcase_13 AC 36 ms
54,036 KB
testcase_14 AC 40 ms
59,520 KB
testcase_15 AC 36 ms
53,152 KB
testcase_16 AC 39 ms
57,712 KB
testcase_17 AC 44 ms
62,480 KB
testcase_18 AC 47 ms
68,248 KB
testcase_19 AC 49 ms
68,492 KB
testcase_20 AC 35 ms
53,620 KB
testcase_21 AC 51 ms
69,624 KB
testcase_22 AC 36 ms
53,084 KB
testcase_23 AC 51 ms
70,152 KB
testcase_24 AC 37 ms
53,440 KB
testcase_25 AC 50 ms
69,456 KB
testcase_26 AC 37 ms
52,988 KB
testcase_27 AC 90 ms
75,496 KB
testcase_28 AC 37 ms
53,356 KB
testcase_29 AC 89 ms
75,588 KB
testcase_30 AC 36 ms
52,204 KB
testcase_31 AC 36 ms
52,868 KB
testcase_32 AC 37 ms
53,668 KB
testcase_33 AC 36 ms
54,428 KB
testcase_34 AC 36 ms
52,620 KB
testcase_35 AC 37 ms
53,344 KB
testcase_36 AC 36 ms
53,168 KB
testcase_37 AC 36 ms
52,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from sys import stdin, setrecursionlimit
    # setrecursionlimit(1000000)
    input = stdin.readline
    def iinput(): return int(input())
    def sinput(): return input().rstrip()
    def i0input(): return int(input()) - 1
    def linput(): return list(input().split())
    def liinput(): return list(map(int, input().split()))
    def miinput(): return map(int, input().split())
    def li0input(): return list(map(lambda x: int(x) - 1, input().split()))
    def mi0input(): return map(lambda x: int(x) - 1, input().split())
    INF = 1000000000000000000
    MOD = 998244353

    N = iinput()
    M = iinput()

    if M > N:
        print(0)
        return

    def modinv(a):
        b = MOD
        u, v = 1, 0
        while b > 0:
            t = a // b
            a -= t * b
            a, b = b, a
            u -= t * v
            u, v = v, u
        return u % MOD

    ans = pow(2, N % (MOD - 1), MOD)
    tmp = 1
    for k in range(M):
        ans -= tmp
        ans %= MOD
        tmp *= N - k
        tmp %= MOD
        tmp *= modinv(k + 1)
        tmp %= MOD
    print(ans)

main()
0