結果

問題 No.7 プライムナンバーゲーム
ユーザー gemmarogemmaro
提出日時 2020-06-28 12:48:05
言語 Ruby
(3.2.2)
結果
AC  
実行時間 1,089 ms / 5,000 ms
コード長 346 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 11,232 KB
実行使用メモリ 69,980 KB
最終ジャッジ日時 2023-07-24 21:38:09
合計ジャッジ時間 11,138 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
15,364 KB
testcase_01 AC 92 ms
15,324 KB
testcase_02 AC 1,089 ms
69,980 KB
testcase_03 AC 271 ms
27,500 KB
testcase_04 AC 175 ms
20,392 KB
testcase_05 AC 175 ms
20,300 KB
testcase_06 AC 537 ms
36,604 KB
testcase_07 AC 439 ms
33,544 KB
testcase_08 AC 308 ms
29,568 KB
testcase_09 AC 676 ms
44,044 KB
testcase_10 AC 93 ms
15,384 KB
testcase_11 AC 444 ms
33,576 KB
testcase_12 AC 895 ms
62,524 KB
testcase_13 AC 925 ms
65,448 KB
testcase_14 AC 1,087 ms
69,812 KB
testcase_15 AC 1,049 ms
69,656 KB
testcase_16 AC 1,003 ms
69,664 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def solve
  return 'Lose' if N == 2 || N == 3

  require 'prime'
  primes = Prime.each(10_000).to_a

  result = (4..N).map { _1 - 2 }.each_with_object([false, false]) do |i, r|
    r << primes.select { _1 <= i }
               .any? { !(r[i - _1]) }
  end

  result[-1] ? :Win : :Lose
end

N = gets.to_i

puts solve
0