結果

問題 No.1528 Not 1
ユーザー simansiman
提出日時 2021-06-21 14:17:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 11,336 KB
実行使用メモリ 18,344 KB
最終ジャッジ日時 2023-09-05 01:52:36
合計ジャッジ時間 4,936 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,260 KB
testcase_01 AC 137 ms
17,912 KB
testcase_02 AC 101 ms
16,208 KB
testcase_03 AC 107 ms
16,276 KB
testcase_04 AC 131 ms
17,784 KB
testcase_05 AC 93 ms
15,828 KB
testcase_06 AC 116 ms
16,868 KB
testcase_07 AC 134 ms
18,288 KB
testcase_08 AC 107 ms
16,664 KB
testcase_09 AC 96 ms
15,916 KB
testcase_10 AC 110 ms
16,388 KB
testcase_11 AC 88 ms
15,356 KB
testcase_12 AC 87 ms
15,056 KB
testcase_13 AC 84 ms
15,172 KB
testcase_14 AC 83 ms
15,284 KB
testcase_15 AC 84 ms
15,172 KB
testcase_16 AC 84 ms
15,276 KB
testcase_17 AC 87 ms
15,308 KB
testcase_18 AC 141 ms
18,236 KB
testcase_19 AC 139 ms
18,344 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:9: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

N = gets.to_i

if N == 1
  puts 1
  exit
end

if N.odd? && N <= 5
  puts -1
  exit
end

memo = Array.new(N + 1, false)
nums = []

2.upto(2) do |n|
  next if memo[n]

  n.step(N, n) do |v|
    if not memo[v]
      memo[v] = true
      nums << v
    end
  end
end

if nums.size < Rational(N, 2).ceil
  nums.delete_at(nums.index(6))
  nums << 6
  nums << 3
end

puts nums.join(' ')
0