結果
問題 |
No.2130 分配方法の数え上げ mod 998244353
|
ユーザー |
![]() |
提出日時 | 2025-03-20 21:08:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 130 ms / 2,000 ms |
コード長 | 615 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 82,356 KB |
実行使用メモリ | 60,168 KB |
最終ジャッジ日時 | 2025-03-20 21:09:31 |
合計ジャッジ時間 | 3,200 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 |
ソースコード
import sys MOD = 998244353 def main(): N = int(sys.stdin.readline()) M = int(sys.stdin.readline()) if M > N: print(0) return mod = MOD b = N % mod t = min(M-1, b) sum_c = 0 current = 1 # C(b, 0) sum_c = current % mod for k in range(1, t + 1): current = current * (b - k + 1) % mod current = current * pow(k, mod-2, mod) % mod sum_c = (sum_c + current) % mod pow_2n = pow(2, N, mod) ans = (pow_2n - sum_c) % mod if ans < 0: ans += mod print(ans) if __name__ == "__main__": main()