結果

問題 No.915 Plus Or Multiple Operation
ユーザー もりを
提出日時 2019-10-25 21:43:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 340 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 82,116 KB
実行使用メモリ 53,092 KB
最終ジャッジ日時 2024-11-07 03:23:34
合計ジャッジ時間 1,308 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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