結果

問題 No.7 プライムナンバーゲーム
ユーザー gemmarogemmaro
提出日時 2020-06-28 12:48:05
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,162 ms / 5,000 ms
コード長 346 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 77,952 KB
最終ジャッジ日時 2024-04-09 04:56:59
合計ジャッジ時間 11,447 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
12,800 KB
testcase_01 AC 106 ms
12,544 KB
testcase_02 AC 1,158 ms
65,792 KB
testcase_03 AC 299 ms
24,704 KB
testcase_04 AC 189 ms
17,536 KB
testcase_05 AC 198 ms
17,408 KB
testcase_06 AC 580 ms
43,008 KB
testcase_07 AC 474 ms
38,656 KB
testcase_08 AC 331 ms
25,728 KB
testcase_09 AC 725 ms
51,968 KB
testcase_10 AC 103 ms
12,672 KB
testcase_11 AC 476 ms
28,800 KB
testcase_12 AC 949 ms
63,360 KB
testcase_13 AC 1,010 ms
65,152 KB
testcase_14 AC 1,162 ms
66,176 KB
testcase_15 AC 1,143 ms
65,280 KB
testcase_16 AC 1,083 ms
77,952 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