結果

問題 No.3186 Big Order
ユーザー Kude
提出日時 2025-06-20 22:52:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 81,984 KB
実行使用メモリ 59,324 KB
最終ジャッジ日時 2025-06-20 22:52:22
合計ジャッジ時間 2,901 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
def max_factor(f, x):
    while x % f == 0:
        x //= f
    x = gcd(f, x)
    if x == 1:
        return f
    return max_factor(x, f)

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

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