結果

問題 No.7 プライムナンバーゲーム
ユーザー tmino5263tmino5263
提出日時 2019-08-01 10:58:40
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 383 bytes
コンパイル時間 14,321 ms
コンパイル使用メモリ 257,500 KB
実行使用メモリ 64,536 KB
最終ジャッジ日時 2023-09-15 12:25:27
合計ジャッジ時間 34,784 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 968 ms
63,036 KB
testcase_01 AC 973 ms
63,264 KB
testcase_02 AC 1,183 ms
63,928 KB
testcase_03 WA -
testcase_04 AC 994 ms
63,460 KB
testcase_05 WA -
testcase_06 AC 1,154 ms
64,336 KB
testcase_07 AC 1,079 ms
63,932 KB
testcase_08 AC 1,076 ms
64,204 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1,102 ms
63,740 KB
testcase_12 AC 1,190 ms
64,536 KB
testcase_13 AC 1,126 ms
63,652 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1,152 ms
64,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

object PrimeNumberGame extends App {
  val N = io.StdIn.readInt()
  val primeNumbers = sieve(Seq.range(2, N), Seq.empty)
  println(s"${if((N - primeNumbers.last) < 2) "Lose" else "Win"}")

  def sieve(numbers: Seq[Int], result: Seq[Int]): Seq[Int] = {
    if(numbers.length == 1) result :+ numbers.head else sieve(numbers.filter(_ % numbers.head != 0), result :+ numbers.head)
  }
}
0