結果

問題 No.915 Plus Or Multiple Operation
ユーザー もりをもりを
提出日時 2019-10-25 21:45:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 71,652 KB
最終ジャッジ日時 2023-08-07 00:16:56
合計ジャッジ時間 2,172 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,552 KB
testcase_01 AC 72 ms
71,320 KB
testcase_02 AC 73 ms
71,444 KB
testcase_03 AC 73 ms
71,652 KB
testcase_04 AC 73 ms
71,328 KB
testcase_05 AC 73 ms
71,360 KB
testcase_06 AC 72 ms
71,332 KB
testcase_07 AC 71 ms
71,076 KB
testcase_08 AC 73 ms
71,592 KB
testcase_09 AC 74 ms
71,300 KB
testcase_10 AC 72 ms
71,492 KB
testcase_11 AC 73 ms
71,352 KB
testcase_12 AC 74 ms
71,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
for i in range(n):
    a,b,c = map(int,input().split())
    if c == 1:
        print(-1)
        continue
    x = 0
    y = 10 ** 100
    while a > 0:
        y = min(y, x + b * ((a + c - 2) // (c - 1)))
        if a % c == 0:
            a //= c
        else:
            a -= a % c
        x += b
    print(min(x, y))
0