結果

問題 No.3186 Big Order
ユーザー akakimidori
提出日時 2025-06-20 23:52:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-06-21 02:43:20
合計ジャッジ時間 3,035 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())

for i in range(0, t):
    a, b, c = [int(s) for s in input().split()]
    ans = 0
    prod = 1
    cnt = 0
    while a % c == 0:
        a //= c
        cnt += 1
    a %= c
    while b > 0:
        if b % 2 == 1:
            prod *= a
            ans += cnt
            if prod % c == 0:
                ans += 1
                prod //= c
            prod %= c
        a = a * a
        cnt *= 2
        if a % c == 0:
            a //= c
            cnt += 1
        a %= c
        b >>= 1
    print(ans % 998244353)
0