結果

問題 No.915 Plus Or Multiple Operation
ユーザー nadarenadare
提出日時 2019-10-25 22:28:44
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
TLE  
実行時間 -
コード長 563 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 108,252 KB
最終ジャッジ日時 2023-08-07 00:25:41
合計ジャッジ時間 6,628 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

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(ans-1)
0