結果
問題 | No.2130 分配方法の数え上げ mod 998244353 |
ユーザー |
|
提出日時 | 2022-11-25 22:10:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 158 ms / 2,000 ms |
コード長 | 785 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 82,272 KB |
実行使用メモリ | 75,580 KB |
最終ジャッジ日時 | 2024-10-02 04:43:22 |
合計ジャッジ時間 | 3,156 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 |
ソースコード
import sys INF = float('inf') #10**20,2**63,float('inf') MOD = 10**9 + 7 MOD2 = 998244353 from collections import defaultdict def solve(): def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LC(): return list(input()) def IC(): return [int(c) for c in input()] def MI(): return map(int, sys.stdin.readline().split()) N = II() M = II() def modinv(x): return pow(x, MOD2 - 2, MOD2) All = pow(2,N,MOD2) Dec = 0 for m in range(M): if(m==0):Dec+=1 elif(m==1): Dec+=N%MOD2 now = N else: now*=(N-(m-1))*modinv(m) now%=MOD2 Dec+=now Dec%=MOD2 print((All-Dec)%MOD2) return solve()