結果
| 問題 | No.2130 分配方法の数え上げ mod 998244353 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-25 23:18:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 750 bytes |
| コンパイル時間 | 270 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 21,504 KB |
| 最終ジャッジ日時 | 2024-12-20 19:59:46 |
| 合計ジャッジ時間 | 62,526 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 20 |
ソースコード
mod = 998244353
def mod_pow(x, n, mod):
result = 1
while n > 0:
if n & 1:
result = result * x % mod
x = x * x % mod
n >>= 1
return result
def mod_inv(x, mod):
return mod_pow(x, mod - 2, mod)
def cmb(n, r, mod):
if n < r:
return 0
if r == 0:
return 1
numerator = denominator = 1
for i in range(r):
numerator = numerator * (n - i) % mod
denominator = denominator * (i + 1) % mod
return numerator * mod_inv(denominator, mod) % mod
def count_ways(N, M, mod):
result = 0
for i in range(N - M + 1):
result += cmb(N, M + i, mod)
result %= mod
return result
N = int(input())
M = int(input())
print(count_ways(N, M, mod))