結果

問題 No.915 Plus Or Multiple Operation
ユーザー ntuda
提出日時 2025-01-02 16:18:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 53,552 KB
最終ジャッジ日時 2025-01-02 16:18:30
合計ジャッジ時間 1,500 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    a,b,c = map(int,input().split())
    i = 0
    if c == 1:
        print(-1)
        continue
    while a > 0:
        if a < c:
            a = 0
        elif a < 2 * c - 1:
            a = 0
            i += 1
        elif a % c == 0:
            a //= c
        else:
            a -= a % c
        i += 1
    print(b * i)
0