結果
| 問題 | No.3462 Buttons |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-27 10:17:25 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
AC
|
| 実行時間 | 1,334 ms / 2,000 ms |
| コード長 | 883 bytes |
| 記録 | |
| コンパイル時間 | 687 ms |
| コンパイル使用メモリ | 20,824 KB |
| 実行使用メモリ | 15,484 KB |
| 最終ジャッジ日時 | 2026-02-28 13:13:03 |
| 合計ジャッジ時間 | 19,493 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 15 |
ソースコード
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 % 2 == 0:
print(2 * a * pow(-b, k-2, mod) % mod)
else:
print(a * pow(-b, k-1, mod) % mod)