結果
問題 | No.2896 Monotonic Prime Factors |
ユーザー |
![]() |
提出日時 | 2024-09-20 22:21:33 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,137 bytes |
コンパイル時間 | 318 ms |
コンパイル使用メモリ | 82,120 KB |
実行使用メモリ | 86,388 KB |
最終ジャッジ日時 | 2024-09-20 22:21:37 |
合計ジャッジ時間 | 3,854 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 RE * 3 |
ソースコード
import sysinput = sys.stdin.readlineclass Factorization():def __init__(self, N):self.L = list(range(N + 1))for i in range(2, N + 1):if i != self.L[i]:continuefor j in range(2 * i, N + 1, i):self.L[j] = idef get(self, n):if n <= 1:return []D = []while n != 1:cnt = 0now = self.L[n]while n % now == 0:cnt += 1n //= nowD.append((now, cnt))return DQ = int(input())mod = 998244353n = 505050fact = [1] * (n + 1)invfact = [1] * (n + 1)for i in range(1, n):fact[i + 1] = ((i+1) * fact[i]) % modinvfact[n] = pow(fact[n], mod - 2, mod)for i in range(n - 1, -1, -1):invfact[i] = invfact[i + 1] * (i + 1) % moddef comb(n, r):if n < 0 or r < 0 or n - r < 0:return 0return fact[n] * invfact[r] * invfact[n - r] % modF = Factorization(10**5+5)now = 0for i in range(Q):a, b = map(int, input().split())for _, v in F.get(a):now += vprint(comb(now - 1, b - 1))