結果
問題 |
No.3186 Big Order
|
ユーザー |
|
提出日時 | 2025-06-20 23:29:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 153 ms / 2,000 ms |
コード長 | 489 bytes |
コンパイル時間 | 396 ms |
コンパイル使用メモリ | 82,632 KB |
実行使用メモリ | 77,468 KB |
最終ジャッジ日時 | 2025-06-21 02:43:16 |
合計ジャッジ時間 | 5,898 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
import math def calc(A, B, C): if B == 0: return 0, 1 x, y = calc(A, B // 2, C) x += x if x >= 998244353: x -= 998244353 y = y * y if B % 2 == 1: y *= A while y % C == 0: y //= C x += 1 if x >= 998244353: x -= 998244353 return x, math.gcd(y, C) def solve(): A, B, C = map(int, input().split()) ans = 0 while A % C == 0: A //= C ans += B A = math.gcd(A, C) x, y = calc(A, B, C) ans += x ans %= 998244353 print(ans) T = int(input()) for _ in range(T): solve()