結果
問題 |
No.3186 Big Order
|
ユーザー |
![]() |
提出日時 | 2025-06-20 23:01:04 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 761 bytes |
コンパイル時間 | 390 ms |
コンパイル使用メモリ | 82,168 KB |
実行使用メモリ | 81,180 KB |
最終ジャッジ日時 | 2025-06-20 23:01:31 |
合計ジャッジ時間 | 4,223 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 WA * 14 RE * 14 |
ソースコード
from math import gcd def extract(a, x): if a == 0: return x a = gcd(a, x) x //= a while True: g = gcd(a, x) if g == 1: return a x //= g a *= g def max_factor(f, x): while x % f == 0: x //= f x = extract(f, x) if x == 1: return f return max_factor(x, f) def solve(a, b, c): ans = 0 while a % c == 0: a //= c ans += b g = gcd(c, a) if g == 1: return ans 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 ans + ea * b // ec for _ in range(int(input())): print(solve(*map(int, input().split())) % 998244353)