結果

問題 No.2896 Monotonic Prime Factors
ユーザー rlangevinrlangevin
提出日時 2024-09-20 22:24:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 1,142 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,136 KB
実行使用メモリ 109,012 KB
最終ジャッジ日時 2024-09-20 22:25:09
合計ジャッジ時間 5,040 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
95,476 KB
testcase_01 AC 92 ms
95,516 KB
testcase_02 AC 92 ms
95,480 KB
testcase_03 AC 91 ms
95,236 KB
testcase_04 AC 197 ms
108,792 KB
testcase_05 AC 240 ms
108,940 KB
testcase_06 AC 222 ms
108,884 KB
testcase_07 AC 199 ms
108,844 KB
testcase_08 AC 197 ms
108,920 KB
testcase_09 AC 231 ms
108,568 KB
testcase_10 AC 168 ms
108,492 KB
testcase_11 AC 160 ms
108,820 KB
testcase_12 AC 130 ms
108,480 KB
testcase_13 AC 176 ms
108,672 KB
testcase_14 AC 192 ms
108,676 KB
testcase_15 AC 114 ms
107,000 KB
testcase_16 AC 142 ms
108,896 KB
testcase_17 AC 136 ms
109,012 KB
testcase_18 AC 230 ms
108,796 KB
testcase_19 AC 138 ms
108,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

class Factorization():
    def __init__(self, N):
        self.L = list(range(N + 1))
        for i in range(2, N + 1):
            if i != self.L[i]:
                continue
            for j in range(2 * i, N + 1, i):
                self.L[j] = i

    def get(self, n):
        if n <= 1:
            return []
        D = []
        while n != 1:
            cnt = 0
            now = self.L[n]
            while n % now == 0:
                cnt += 1
                n //= now
            D.append((now, cnt))
        return D


Q = int(input())
mod = 998244353
n = 2 * 10 ** 6
fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod

def comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n - r] % mod

F = Factorization(10**5+5)
now = 0
for i in range(Q):
    a, b = map(int, input().split())
    for _, v in F.get(a):
        now += v
    print(comb(now - 1, b - 1))
0