結果
問題 |
No.1528 Not 1
|
ユーザー |
![]() |
提出日時 | 2021-06-21 14:17:51 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 135 ms / 2,000 ms |
コード長 | 379 bytes |
コンパイル時間 | 197 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 15,232 KB |
最終ジャッジ日時 | 2024-06-22 22:50:01 |
合計ジャッジ時間 | 3,682 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 |
コンパイルメッセージ
Main.rb:9: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
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(' ')