結果

問題 No.915 Plus Or Multiple Operation
ユーザー nadarenadare
提出日時 2019-10-25 22:30:29
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 71,500 KB
最終ジャッジ日時 2023-08-07 00:25:32
合計ジャッジ時間 1,980 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 70 ms
71,364 KB
testcase_06 AC 71 ms
70,904 KB
testcase_07 AC 69 ms
70,896 KB
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 = []
    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(ans-1)
0