結果

問題 No.915 Plus Or Multiple Operation
ユーザー nadarenadare
提出日時 2019-10-25 22:55:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 584 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 8,004 KB
最終ジャッジ日時 2023-08-07 00:29:00
合計ジャッジ時間 1,097 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
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()
    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))
0