結果

問題 No.915 Plus Or Multiple Operation
ユーザー tktk_snsn
提出日時 2020-12-30 03:13:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 81,976 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2024-11-07 03:52:49
合計ジャッジ時間 1,370 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

def test():
    a, b, c = map(int, input().split())
    if c == 1:
        return -1
    n = 0
    while a:
        if a < c:
            n += 1
            break
        if a <= 2 * (c - 1):
            n += 2
            break
        if a % c == 0:
            n += 1
        else:
            n += 2
        a //= c
    return n * b


Q = int(input())
for _ in range(Q):
    print(test())
0