結果
| 問題 |
No.2896 Monotonic Prime Factors
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2024-09-10 23:30:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,436 ms / 2,000 ms |
| コード長 | 964 bytes |
| コンパイル時間 | 404 ms |
| コンパイル使用メモリ | 82,260 KB |
| 実行使用メモリ | 219,380 KB |
| 最終ジャッジ日時 | 2024-09-10 23:30:52 |
| 合計ジャッジ時間 | 21,753 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
MOD = 998244353
# 階乗とその逆元
factorials = [None] * (2 * 10**6 + 1)
factorials[0], factorials[1] = 1, 1
inv = [None] * (2 * 10**6 + 1)
inv[1] = 1
inv_factorials = [None] * (2 * 10**6 + 1)
inv_factorials[0], inv_factorials[1] = 1, 1
for i in range(2, 2 * 10**6 + 1):
factorials[i] = factorials[i - 1] * i % MOD
inv[i] = -inv[MOD % i] * (MOD // i) % MOD
inv_factorials[i] = inv_factorials[i - 1] * inv[i] % MOD
# 二項係数
def comb(n, r):
if n < r:
return 0
return factorials[n] * inv_factorials[r] % MOD * inv_factorials[n - r] % MOD
# 素因数の個数
def factor_count(n):
count = 0
p = 2
while p**2 <= n:
while n % p == 0:
count += 1
n //= p
p += 1
if n > 1:
count += 1
return count
Q = int(input())
cnt = 0
for _ in range(Q):
A, B = map(int, input().split())
cnt += factor_count(A)
ans = comb(cnt - 1, B - 1)
print(ans)