結果

問題 No.7 プライムナンバーゲーム
ユーザー letrangerjpletrangerjp
提出日時 2017-05-13 08:27:33
言語 Ruby
(3.2.2)
結果
AC  
実行時間 234 ms / 5,000 ms
コード長 216 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 11,508 KB
実行使用メモリ 15,548 KB
最終ジャッジ日時 2023-07-24 20:57:24
合計ジャッジ時間 3,681 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,372 KB
testcase_01 AC 82 ms
15,316 KB
testcase_02 AC 234 ms
15,476 KB
testcase_03 AC 90 ms
15,364 KB
testcase_04 AC 85 ms
15,140 KB
testcase_05 AC 86 ms
15,296 KB
testcase_06 AC 125 ms
15,544 KB
testcase_07 AC 110 ms
15,440 KB
testcase_08 AC 97 ms
15,300 KB
testcase_09 AC 157 ms
15,400 KB
testcase_10 AC 81 ms
15,348 KB
testcase_11 AC 112 ms
15,348 KB
testcase_12 AC 192 ms
15,548 KB
testcase_13 AC 194 ms
15,344 KB
testcase_14 AC 231 ms
15,372 KB
testcase_15 AC 216 ms
15,324 KB
testcase_16 AC 209 ms
15,496 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require "prime"

def f(n)
  dp = [true] * (n+1)
  (2..n).each_with_object([]){|i, primes|
    primes << i if i.prime?
    dp[i] = primes.any?{|pr| !dp[i - pr]}
  }
  dp[n]
end

N = gets.to_i
puts f(N) ? :Win : :Lose
0