結果

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

ソースコード

diff #

t = int(input())
#print(t)

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