結果
| 問題 |
No.915 Plus Or Multiple Operation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-26 01:25:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 743 bytes |
| コンパイル時間 | 166 ms |
| コンパイル使用メモリ | 82,148 KB |
| 実行使用メモリ | 66,156 KB |
| 最終ジャッジ日時 | 2024-11-07 03:41:11 |
| 合計ジャッジ時間 | 1,346 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 RE * 4 |
ソースコード
Q = int(input())
for i in range(Q):
A, B, C = map(int, input().split())
if C == 1:
print(-1)
continue
bit = []
while A >= C:
bit.append(A%C)
A //= C
bit.append(A)
bit.reverse()
n = len(bit)
if bit[0]*C+bit[1] <= 2*C-2:
ope = 3 #足して足してビットシフト
for i in range(2, n):
if bit[i] != 0:
ope += 1 #足す
if i < n-1:
ope += 1 #ビットシフト
else:
ope = 0
for i in range(n):
if bit[i] != 0:
ope += 1
if i < n-1:
ope += 1
print(B*ope)