結果

問題 No.7 プライムナンバーゲーム
ユーザー DialBirdDialBird
提出日時 2016-11-14 10:14:58
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 296 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 18,176 KB
最終ジャッジ日時 2024-05-04 11:37:13
合計ジャッジ時間 8,033 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
12,288 KB
testcase_01 AC 90 ms
12,416 KB
testcase_02 AC 90 ms
12,416 KB
testcase_03 AC 89 ms
12,416 KB
testcase_04 AC 88 ms
12,544 KB
testcase_05 AC 102 ms
12,544 KB
testcase_06 AC 87 ms
12,160 KB
testcase_07 AC 84 ms
12,416 KB
testcase_08 AC 89 ms
12,288 KB
testcase_09 AC 198 ms
12,544 KB
testcase_10 AC 84 ms
12,416 KB
testcase_11 AC 84 ms
12,544 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:18: warning: assigned but unused variable - ans
Syntax OK

ソースコード

diff #

require 'prime'

MAX_N = 10000

@dp = [nil]*(MAX_N + 1)

def check(n)
  n.downto(2) do |i|
    next if !i.prime?
    next if [0,1].include?(n-i)
    return @dp[n] = true if !check(n-i)
  end
  return @dp[n] = false
end

def main
  n = gets.to_i
  ans = check(n) ? "Win" : "Lose"
end

puts main() 
0