結果

問題 No.3186 Big Order
ユーザー alcea
提出日時 2025-06-20 22:22:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 579 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 62,528 KB
最終ジャッジ日時 2025-06-20 22:23:07
合計ジャッジ時間 3,795 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 1 -- * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

mod=998244353

def solve():
  a,b,c=map(int,input().split())
  if (a**200)%c!=0:
    print(0)
    return
  g=math.gcd(a,c**200)
  a=g
  res=1
  ans=0
  while b>0 and a!=1:
    a_tmp=a
    d=1
    while a_tmp%c!=0 and d<b:
      a_tmp*=a
      d+=1
    if a_tmp%c!=0:
      res*=a_tmp
      break
    res*=a**(b%d)
    while res%c==0:
      res//=c
      ans+=1
    b//=d
    cnt=0
    while a_tmp%c==0:
      cnt+=1
      a_tmp//=c
    ans=(ans+b*cnt)%mod
    a=a_tmp
  while res%c==0:
    res//=c
    ans+=1
  print(ans)

t=int(input())
for _ in range(t):
  solve()
0