結果

問題 No.1243 約数加算
ユーザー maimai
提出日時 2020-10-02 21:45:00
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 666 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 11,504 KB
実行使用メモリ 15,444 KB
最終ジャッジ日時 2023-09-23 04:32:14
合計ジャッジ時間 2,962 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def lscan; gets.split.map(&:to_i); end

def solve(a, b)
  answer = []
  step = 1
  while a < b
    if b - a == step
      answer << step
      a += step
    elsif b - a < step
      step /= 2
    elsif b - a > step*2
      if a%(step*2) == 0
        step *= 2
      else
        answer << step
        a += step
      end
    else
      answer << step
      a += step
    end
  end
  answer
end

# def check(a, b, ans)
#   p a
#   ans.each do |x|
#     abort "#{x}" unless a%x == 0
#     p a += x
#   end
#   abort `#{a} != #{b}` unless a == b
#   true
# end

gets.to_i.times do 
  a,b = lscan
  ans = solve(a, b)
  p a.size
  puts ans*' '
  # p check(a, b, ans)
end
0