import scala.annotation.tailrec import scala.io.StdIn object Problem007 { def primesIn(min: Int, max: Int) = { val sq = Math.sqrt(max).toInt @tailrec def sieve(xs: Seq[Int], result: Seq[Int]): Seq[Int] = { if (xs.isEmpty || xs.head > sq) { (xs.reverse ++ result).reverse } else { sieve(xs.tail.filter(_ % xs.head != 0), xs.head +: result) } } sieve((2 to max).toSeq, Seq()).filter(_ >= min) } def proc(n: Int): String = { val primes = primesIn(2, n) val win = Array.fill(n + 1)(false) for (i <- 2 to n - 2 if !win(i)) { for (prime <- primes if i + prime <= n) { win(i + prime) = true } } if (win(n)) "Win" else "Lose" } def main(args: Array[String]) { val n = StdIn.readInt() val result = proc(n) println(result) } }