require 'prime' # 素数列挙 prime_generator = Prime::EratosthenesGenerator.new @primes = [] begin ; @primes << prime_generator.next ; end while @primes[-1]<10000 @a = Array.new(10010) @a[0] = true @a[1] = true # win?(num) numは先手必勝か後手必勝 def win?(n) @primes.each{|k| return false if n-k<0 return true if !@a[n-k] } return false end 2.upto(10000){|i| @a[i] = win?(i) } puts @a[gets.to_i] ? "Win" : "Lose"