結果
| 問題 | No.3186 Big Order |
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2025-06-20 23:01:04 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 761 bytes |
| 記録 | |
| コンパイル時間 | 224 ms |
| コンパイル使用メモリ | 95,856 KB |
| 実行使用メモリ | 102,416 KB |
| 最終ジャッジ日時 | 2026-07-12 15:55:54 |
| 合計ジャッジ時間 | 6,914 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 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)
Kude