結果
| 問題 | No.3462 Buttons |
| コンテスト | |
| ユーザー |
まぬお
|
| 提出日時 | 2026-02-28 14:51:34 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,150 bytes |
| 記録 | |
| コンパイル時間 | 354 ms |
| コンパイル使用メモリ | 77,996 KB |
| 実行使用メモリ | 75,088 KB |
| 最終ジャッジ日時 | 2026-02-28 14:51:43 |
| 合計ジャッジ時間 | 6,836 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 15 |
ソースコード
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, groupby
from heapq import heappop, heappush
import math, sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
def printl(li, sep=" "): print(sep.join(map(str, li)))
def yn(flag): print(Yes if flag else No)
_int = lambda x: int(x)-1
MOD = 998244353 #10**9+7
INF = 1<<60
Yes, No = "Yes", "No"
def solve():
A, B, K = map(int, input().split())
if A == 0:
print(0)
return
if 0 <= B <= 1:
if A < 0:
print(0)
else:
print(A*K)
return
if B == -1:
if A < 0:
print(A*(K-1))
else:
print(A*K)
return
if B > 1:
if A < 0:
print(0)
else: # A > 0
print(A*pow(B, K-1, MOD)%MOD)
else: # B < -1
if A < 0:
if K&1:
print(-A*2*pow(-B, K-2, MOD)%MOD)
else:
print(-A*pow(-B, K-1, MOD)%MOD)
else:
print(A*K)
return
for _ in range(int(input())):
solve()
まぬお