結果

問題 No.915 Plus Or Multiple Operation
ユーザー pluto77pluto77
提出日時 2019-12-26 16:53:02
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 248 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-11-07 03:44:00
合計ジャッジ時間 1,201 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki915

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