結果
| 問題 | 
                            No.2896 Monotonic Prime Factors
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-09-20 22:26:01 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,501 bytes | 
| コンパイル時間 | 157 ms | 
| コンパイル使用メモリ | 81,776 KB | 
| 実行使用メモリ | 113,884 KB | 
| 最終ジャッジ日時 | 2024-09-20 22:26:14 | 
| 合計ジャッジ時間 | 10,053 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 16 RE * 2 | 
ソースコード
import sys
import math
from functools import lru_cache
# モジュール化している組み合わせ (NCR) を計算するクラス
class NCR:
    def __init__(self, mod=998244353, max_n=1500020):
        self.mod = mod
        self.fact = [1] * (max_n + 1)
        self.inv = [1] * (max_n + 1)
        self.inv_fact = [1] * (max_n + 1)
        for i in range(2, max_n + 1):
            self.fact[i] = self.fact[i - 1] * i % mod
            self.inv[i] = mod - self.inv[mod % i] * (mod // i) % mod
            self.inv_fact[i] = self.inv_fact[i - 1] * self.inv[i] % mod
    def nCr(self, n, r):
        if n < r:
            return 0
        x = self.fact[n]
        y = self.inv_fact[n - r]
        z = self.inv_fact[r]
        return x * (y * z % self.mod) % self.mod
# 素因数分解
def prime_factorize(N):
    res = []
    p = 2
    while p * p <= N:
        if N % p != 0:
            p += 1
            continue
        e = 0
        while N % p == 0:
            e += 1
            N //= p
        res.append((p, e))
        p += 1
    if N != 1:
        res.append((N, 1))
    return res
# 組み合わせのためのオブジェクト生成
ncr = NCR()
# 処理の本体
def f(sm, b):
    print(ncr.nCr(sm - 1, b - 1))
# メイン処理
def main():
    sm = 0
    n = int(input())
    for _ in range(n):
        a, b = map(int, input().split())
        res = prime_factorize(a)
        for p, e in res:
            sm += e
        f(sm, b)
if __name__ == "__main__":
    main()