結果

問題 No.915 Plus Or Multiple Operation
ユーザー もりをもりを
提出日時 2019-10-25 21:44:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 390 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 81,980 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2024-04-24 18:34:46
合計ジャッジ時間 1,710 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 41 ms
52,096 KB
testcase_04 AC 43 ms
52,096 KB
testcase_05 AC 41 ms
52,224 KB
testcase_06 AC 42 ms
51,840 KB
testcase_07 AC 41 ms
51,712 KB
testcase_08 AC 40 ms
52,096 KB
testcase_09 AC 42 ms
51,712 KB
testcase_10 AC 40 ms
51,968 KB
testcase_11 AC 42 ms
51,840 KB
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
for i in range(n):
    a,b,c = map(int,input().split())
    if c == 1:
        print(-1)
        continue
    if c == 2:
        print(a * b)
        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