結果
| 問題 | No.915 Plus Or Multiple Operation |
| コンテスト | |
| ユーザー |
nadare
|
| 提出日時 | 2019-10-25 22:56:00 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 585 bytes |
| 記録 | |
| コンパイル時間 | 370 ms |
| コンパイル使用メモリ | 20,956 KB |
| 実行使用メモリ | 15,392 KB |
| 最終ジャッジ日時 | 2026-05-07 11:54:30 |
| 合計ジャッジ時間 | 2,474 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 2 |
ソースコード
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
for _ in range(int(input())):
a, b, c = inpl()
if c == 1:
print(a*b)
continue
Q = []
d = c - 1
hoge = -(-a//(c-1))
ans = 0
# print(a, end = " ")
while a:
a, m = divmod(a, c)
Q.append(m)
# print(Q, end = " ")
if (len(Q) >= 2) and (Q[-1] == 1) and (1 <= Q[-2] <= c-2):
ans += 3
Q.pop()
Q.pop()
while Q:
x = Q.pop()
ans += 1 + (x > 0)
print(b*min(ans-1, hoge))
nadare