結果
| 問題 |
No.3186 Big Order
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-20 22:37:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 1,196 bytes |
| コンパイル時間 | 423 ms |
| コンパイル使用メモリ | 82,584 KB |
| 実行使用メモリ | 67,524 KB |
| 最終ジャッジ日時 | 2025-06-21 02:42:57 |
| 合計ジャッジ時間 | 3,262 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 35 |
ソースコード
import math
mod=998244353
def slv():
A,B,C=map(int,input().split())
ps=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
# print(len(ps))
def calc(p:int)->int:
a,b,c=A,B,C
ca,cc=0,0
while a%p==0:
a//=p
ca+=1
while c%p==0:
c//=p
cc+=1
return (10**50 if cc==0 else (ca*b)//cc,a,c)
ret=10**50
for p in ps:
t,A,C=calc(p)
ret=min(ret,t)
if C>1:
tmp=0
tmp2=1
while A%C==0:
tmp+=B
A//=C
while B>1:
A=math.gcd(A,C)
t=-1
a=A
for i in range(1,21):
if a%C==0:
t=i
break
a*=A
if t==-1:break
tmp2*=pow(A,B%t)
while tmp2%C==0:
tmp2//=C
tmp+=1
tmp+=B//t
B//=t
A=a//C
tmp2*=A
while tmp2%C==0:
tmp2//=C
tmp+=1
ret=min(ret,tmp)
print(ret%mod)
T=int(input())
while T:
T-=1
slv()