結果

問題 No.915 Plus Or Multiple Operation
ユーザー curi_kucuri_ku
提出日時 2019-10-26 01:08:54
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 385 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-07 03:41:07
合計ジャッジ時間 1,081 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

Q = int(input())
for i in range(Q):
  A,B,C = [int(x) for x in input().split()]
  ans = 0
  if C==1:
    print(-1)
    continue
  while A>C:
    #print(A)
    if A<=2*(C-1):
      ans+=2
      A=1
      break
    if A%C!=0:
      A = A-A%C
      ans+=1
    if A==C:
      ans+=2
      A=1
      break
    A = A/C
    ans+=1
  if A==C:
    ans+=2
  elif A!=1:
    ans+=1
  print(ans*B)
0