結果

問題 No.7 プライムナンバーゲーム
ユーザー 💕💖💞💕💖💞
提出日時 2017-04-08 16:33:39
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 481 ms / 5,000 ms
コード長 578 bytes
コンパイル時間 11,879 ms
コンパイル使用メモリ 433,008 KB
実行使用メモリ 91,528 KB
最終ジャッジ日時 2024-04-09 04:13:46
合計ジャッジ時間 20,320 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 332 ms
60,372 KB
testcase_01 AC 340 ms
60,456 KB
testcase_02 AC 470 ms
91,468 KB
testcase_03 AC 439 ms
66,624 KB
testcase_04 AC 372 ms
60,480 KB
testcase_05 AC 376 ms
60,708 KB
testcase_06 AC 438 ms
77,048 KB
testcase_07 AC 433 ms
72,908 KB
testcase_08 AC 427 ms
68,740 KB
testcase_09 AC 455 ms
81,064 KB
testcase_10 AC 338 ms
60,372 KB
testcase_11 AC 429 ms
72,928 KB
testcase_12 AC 461 ms
91,288 KB
testcase_13 AC 463 ms
91,448 KB
testcase_14 AC 472 ms
91,528 KB
testcase_15 AC 467 ms
91,408 KB
testcase_16 AC 481 ms
91,388 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) { 
         ^
Main.kt:3:38: warning: parameter 'x' is never used, could be renamed to _
  val prime_check = (0..10001).map { x -> 1 }.toMutableList()
                                     ^

ソースコード

diff #

fun main(args: Array<String>) { 
  val n = readLine()!!.toInt()
  val prime_check = (0..10001).map { x -> 1 }.toMutableList()
  val prime_list:MutableList<Int> = mutableListOf()
  val dp:MutableSet<Int> = mutableSetOf(0, 1)
  (2..n+1).map { x -> 
    if(prime_check[x] == 1) { 
      prime_list.add(x)
      (x*2..10001 step x).map { x2 ->
        prime_check[x2] = 0
      }
    }
    for(x2 in prime_list) { 
      if( !dp.contains(x - x2) ) {
        dp.add(x)
        break
      }
    }
  }
  if( dp.contains(n) ) { 
    println("Win")
  } else {
    println("Lose")
  }
}
0