結果

問題 No.688 E869120 and Constructing Array 2
ユーザー letrangerjpletrangerjp
提出日時 2018-05-18 22:51:41
言語 Ruby
(3.2.2)
結果
AC  
実行時間 85 ms / 1,000 ms
コード長 289 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 11,240 KB
実行使用メモリ 15,460 KB
最終ジャッジ日時 2023-09-21 20:00:44
合計ジャッジ時間 2,230 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,324 KB
testcase_01 AC 85 ms
15,212 KB
testcase_02 AC 82 ms
15,184 KB
testcase_03 AC 83 ms
15,208 KB
testcase_04 AC 82 ms
15,200 KB
testcase_05 AC 82 ms
15,060 KB
testcase_06 AC 82 ms
15,240 KB
testcase_07 AC 82 ms
15,460 KB
testcase_08 AC 82 ms
15,312 KB
testcase_09 AC 82 ms
15,132 KB
testcase_10 AC 81 ms
15,240 KB
testcase_11 AC 81 ms
15,404 KB
testcase_12 AC 81 ms
15,400 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

K = gets.to_i
case K
when 0
  p 1, 0
when 1
  p 2, 1, 1
when 2
  p 3, 0, 1, 1
else
  s = 0
  a = (1..30).map{|j|
    s += j
  }
  a.each.with_index(2){|b, i|
    n = Math.log2(K / b).floor
    if b * 2**n == K
      p i + n
      n.times{p 0}
      i.times{p 1}
      exit
    end
  }
end
0