結果
| 問題 |
No.3186 Big Order
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-20 23:35:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 251 ms / 2,000 ms |
| コード長 | 1,114 bytes |
| コンパイル時間 | 245 ms |
| コンパイル使用メモリ | 82,172 KB |
| 実行使用メモリ | 76,504 KB |
| 最終ジャッジ日時 | 2025-06-21 02:43:13 |
| 合計ジャッジ時間 | 3,675 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 35 |
ソースコード
import math
mod=998244353
def intsqrt(n):
dig=0
while pow(10,2*dig) < n:
dig+=1
sq=0
for k in reversed(range(0,dig+1)):
for l in range(0,10):
sq+=10**k
if sq*sq==n:
break
if sq*sq>n:
sq-=10**k
break
return sq
def solve():
a,b,c=map(int,input().split())
a=math.gcd(a,c**140)
ans=b*200
i=0
while i<140:
i+=1
if c==1:
break
a_tmp=a**i
while a_tmp%c==0:
a_tmp//=c
#print(f"!{a_tmp}")
c_tmp=c
g=-1
while g!=1:
g=math.gcd(a_tmp,c_tmp)
c_tmp//=g
if c_tmp>1:
if i==1:
c_tmp=c_tmp
elif i==2:
c_tmp=intsqrt(c_tmp)
else:
c_tmp=math.floor(c_tmp**(1/i)+0.001)
#print(f"?{c_tmp}")
if c_tmp<=1:
continue
c_cnt=0
while c%c_tmp==0:
c//=c_tmp
c_cnt+=1
a_cnt=0
while a%c_tmp==0:
a//=c_tmp
a_cnt+=1
ans=min(ans,a_cnt*b//c_cnt)
i=0
print(ans%mod if c==1 else 0)
t=int(input())
for _ in range(t):
solve()