結果

問題 No.7 プライムナンバーゲーム
ユーザー gemmarogemmaro
提出日時 2020-06-28 12:31:41
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 325 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 11,376 KB
実行使用メモリ 69,936 KB
最終ジャッジ日時 2023-09-21 18:37:56
合計ジャッジ時間 9,742 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
15,472 KB
testcase_01 AC 89 ms
15,556 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 172 ms
20,460 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 633 ms
43,912 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 845 ms
65,088 KB
testcase_14 AC 975 ms
69,836 KB
testcase_15 AC 940 ms
69,928 KB
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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).each_with_object([false, false]) do |i, r|
    r << primes.select { _1 <= i - 2 }.any? { !(r[N - 2 - _1]) }
  end

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

N = gets.to_i

puts solve
0