結果

問題 No.3186 Big Order
コンテスト
ユーザー KumaTachiRen
提出日時 2025-06-20 22:14:47
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 476 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 236 ms
コンパイル使用メモリ 95,852 KB
実行使用メモリ 246,060 KB
最終ジャッジ日時 2026-07-12 15:31:17
合計ジャッジ時間 4,814 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 1 -- * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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, y

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()
0