結果

問題 No.1528 Not 1
ユーザー simansiman
提出日時 2021-06-21 14:17:08
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 348 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 11,588 KB
実行使用メモリ 18,352 KB
最終ジャッジ日時 2023-09-05 01:52:29
合計ジャッジ時間 7,248 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,164 KB
testcase_01 AC 127 ms
18,240 KB
testcase_02 AC 97 ms
16,236 KB
testcase_03 AC 102 ms
16,292 KB
testcase_04 AC 125 ms
17,868 KB
testcase_05 AC 91 ms
15,800 KB
testcase_06 AC 112 ms
17,048 KB
testcase_07 AC 131 ms
18,180 KB
testcase_08 AC 105 ms
16,472 KB
testcase_09 AC 91 ms
15,672 KB
testcase_10 AC 105 ms
16,440 KB
testcase_11 WA -
testcase_12 AC 83 ms
15,172 KB
testcase_13 AC 80 ms
15,196 KB
testcase_14 AC 82 ms
15,100 KB
testcase_15 AC 79 ms
15,148 KB
testcase_16 AC 79 ms
15,316 KB
testcase_17 AC 81 ms
15,020 KB
testcase_18 AC 136 ms
18,352 KB
testcase_19 AC 134 ms
18,328 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:4: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

N = gets.to_i

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