結果

問題 No.915 Plus Or Multiple Operation
ユーザー nadarenadare
提出日時 2019-10-25 22:31:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,364 KB
実行使用メモリ 71,632 KB
最終ジャッジ日時 2023-08-07 00:25:52
合計ジャッジ時間 2,101 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 71 ms
71,248 KB
testcase_02 AC 72 ms
71,444 KB
testcase_03 AC 73 ms
71,380 KB
testcase_04 AC 73 ms
71,364 KB
testcase_05 AC 72 ms
71,240 KB
testcase_06 AC 72 ms
71,036 KB
testcase_07 AC 71 ms
71,372 KB
testcase_08 AC 71 ms
71,528 KB
testcase_09 AC 73 ms
71,196 KB
testcase_10 AC 72 ms
71,156 KB
testcase_11 AC 72 ms
71,324 KB
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

for _ in range(int(input())):
    a, b, c = inpl()

#for a in range(1, 28):
#    b, c = 1, 3
    if c == 1:
        print(a*b)
        continue

    Q = []
    ans = 0
    
    while a:
        a, m = divmod(a, c)
        Q.append(m)
    
#    print(Q[::-1], 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*(ans-1))
0