結果

問題 No.915 Plus Or Multiple Operation
コンテスト
ユーザー ああ
提出日時 2026-05-22 22:49:20
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 314 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 404 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2026-05-22 22:49:27
合計ジャッジ時間 2,656 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

for _ in range(int(input())):
    a,b,c=map(int,input().split())
    if c==1:
        print(-1)
        continue
    ans=0
    k=a
    x=[]
    while a:
    	if a%c:
    		ans+=b
    	x.append(a%c)
    	a//=c
    	if a:
    		ans+=b
    x.reverse()
    if len(x)>=2 and x[0]==1 and x[1]:
    	ans-=b
    print(ans)
0