結果

問題 No.915 Plus Or Multiple Operation
ユーザー 👑 H20H20
提出日時 2021-10-01 16:10:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 71,460 KB
最終ジャッジ日時 2023-09-26 08:59:45
合計ジャッジ時間 2,581 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,148 KB
testcase_01 AC 70 ms
71,116 KB
testcase_02 AC 71 ms
71,056 KB
testcase_03 AC 70 ms
71,240 KB
testcase_04 AC 72 ms
71,400 KB
testcase_05 AC 72 ms
71,244 KB
testcase_06 AC 76 ms
71,108 KB
testcase_07 AC 72 ms
71,268 KB
testcase_08 AC 71 ms
71,116 KB
testcase_09 AC 71 ms
70,940 KB
testcase_10 AC 71 ms
70,952 KB
testcase_11 AC 71 ms
71,156 KB
testcase_12 AC 72 ms
71,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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



0