結果

問題 No.3186 Big Order
ユーザー Kude
提出日時 2025-06-21 09:06:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 725 bytes
コンパイル時間 417 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 63,816 KB
最終ジャッジ日時 2025-06-21 09:06:53
合計ジャッジ時間 3,347 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

# returns prod of scaled factors with slope (vp(a),vb(b)) max, assuming slope (0,0)=-inf
# i.e. prod_{(vp(a),vp(b))//(s,t)} p^((vp(a)+vp(b))/(s+t)), where slope (s,t) is max
# if a=b=1, returns 0
def max_factor(a, b):
    if b == 1: return 0 if a == 1 else a
    while a != 1:
        if a % b == 0: a //= b
        elif b % a == 0: b //= a
        else: a = gcd(a, b)
    return b

def solve(a, b, c):
    ans = 0
    f = max_factor(a, c)
    ea = ec = 0
    while a % f == 0:
        a //= f
        ea += 1
    while c % f == 0:
        c //= f
        ec += 1
    print(f, ea, ec)
    return ans + ea * b // ec

for _ in range(int(input())):
    print(solve(*map(int, input().split())) % 998244353)
0