結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー 👑 timitimi
提出日時 2022-11-26 11:49:02
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 2,415 ms
コンパイル使用メモリ 86,520 KB
実行使用メモリ 76,612 KB
最終ジャッジ日時 2023-07-25 21:55:45
合計ジャッジ時間 5,442 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,988 KB
testcase_01 AC 74 ms
70,680 KB
testcase_02 AC 76 ms
71,208 KB
testcase_03 AC 75 ms
71,104 KB
testcase_04 AC 76 ms
71,184 KB
testcase_05 AC 75 ms
71,200 KB
testcase_06 AC 74 ms
70,972 KB
testcase_07 AC 73 ms
70,924 KB
testcase_08 AC 76 ms
71,196 KB
testcase_09 AC 78 ms
70,972 KB
testcase_10 AC 76 ms
70,832 KB
testcase_11 AC 76 ms
70,844 KB
testcase_12 AC 75 ms
70,916 KB
testcase_13 AC 74 ms
70,976 KB
testcase_14 AC 81 ms
75,052 KB
testcase_15 AC 80 ms
75,128 KB
testcase_16 AC 78 ms
74,752 KB
testcase_17 AC 85 ms
76,024 KB
testcase_18 AC 90 ms
76,280 KB
testcase_19 AC 88 ms
76,352 KB
testcase_20 AC 73 ms
71,048 KB
testcase_21 AC 90 ms
76,092 KB
testcase_22 AC 74 ms
70,988 KB
testcase_23 AC 89 ms
76,168 KB
testcase_24 AC 74 ms
70,928 KB
testcase_25 AC 89 ms
76,612 KB
testcase_26 AC 73 ms
70,928 KB
testcase_27 AC 137 ms
76,172 KB
testcase_28 AC 73 ms
71,104 KB
testcase_29 AC 137 ms
76,228 KB
testcase_30 AC 73 ms
70,992 KB
testcase_31 AC 74 ms
70,836 KB
testcase_32 AC 78 ms
70,888 KB
testcase_33 AC 76 ms
71,068 KB
testcase_34 AC 75 ms
71,120 KB
testcase_35 AC 75 ms
71,140 KB
testcase_36 AC 76 ms
71,076 KB
testcase_37 AC 75 ms
70,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
M=int(input())
mod=998244353
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
gt=modinv(3,mod)
c=1
ans=1
for i in range(1,M):
  c*=(N+1-i)
  c%=mod
  c*=modinv(i,mod)
  ans+=c
print((pow(2,N,mod)-ans)%mod)
0