結果
問題 |
No.3186 Big Order
|
ユーザー |
|
提出日時 | 2025-06-20 23:15:53 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 781 bytes |
コンパイル時間 | 428 ms |
コンパイル使用メモリ | 82,216 KB |
実行使用メモリ | 82,560 KB |
最終ジャッジ日時 | 2025-06-20 23:16:02 |
合計ジャッジ時間 | 7,434 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | RE * 5 TLE * 1 -- * 28 |
ソースコード
import math mod=998244353 def solve(): a,b,c=map(int,input().split()) ans=b*200 for i in range(1,140): if c==1: break #print(a,c) a_tmp=a**i s_cnt=0 while a_tmp%c==0: a_tmp//=c s_cnt+=1 if a_tmp==1: ans=min(ans,s_cnt*b) c=1 break c_tmp=c g=-1 while g!=1: g=math.gcd(a_tmp,c_tmp) c_tmp//=g if c_tmp>1: #print(i,c_tmp) c_tmp=math.floor(math.pow(c_tmp,1/i)+0.0001) if c_tmp<=1: continue c_cnt=0 #print(c_tmp) 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) print(ans%mod if c==1 else 0) t=int(input()) for _ in range(t): solve()