結果

問題 No.3462 Buttons
コンテスト
ユーザー tyawanmusi
提出日時 2026-02-27 10:13:26
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 965 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,176 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2026-02-28 13:13:00
合計ジャッジ時間 19,471 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
for _ in range(int(input())):
    a, b, k = map(int, input().split())
    mod = 998244353
    if b == 1 or b == 0:
        print(max(a, 0) * k % mod)
        continue
    if b == -1:
        if a >= 0:
            print(a * k % mod)
        else:
            print(- a * (k - 1) % mod)
        continue
    if a < 0:
        if b > 0:
            print(0)
        else:
            if k == 1:
                print(0)
            else:
                if k % 2 == 0:
                    print(- a * pow(-b, k-1, mod) % mod)
                else:
                    print(- 2 * a * pow(-b, k-2, mod) % mod)
    else:
        if b > 0:
            print(a * pow(b, k-1, mod) % mod)
        else:
            if k == 1:
                print(a)
            else:
                if k % 2 == 0:
                    print(a * pow(-b, k-1, mod) % mod)
                else:
                    print(2 * a * pow(-b, k-2, mod) % mod)
0