結果

問題 No.726 Tree Game
ユーザー Pump0129Pump0129
提出日時 2018-08-24 22:28:18
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,488 bytes
コンパイル時間 11,926 ms
コンパイル使用メモリ 427,096 KB
実行使用メモリ 55,180 KB
最終ジャッジ日時 2023-08-13 00:19:36
合計ジャッジ時間 21,369 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 281 ms
52,628 KB
testcase_01 AC 285 ms
52,820 KB
testcase_02 AC 271 ms
52,676 KB
testcase_03 AC 274 ms
52,624 KB
testcase_04 AC 285 ms
52,580 KB
testcase_05 AC 274 ms
52,748 KB
testcase_06 AC 276 ms
52,652 KB
testcase_07 AC 273 ms
52,628 KB
testcase_08 AC 272 ms
52,780 KB
testcase_09 WA -
testcase_10 AC 276 ms
52,696 KB
testcase_11 AC 270 ms
52,936 KB
testcase_12 AC 277 ms
52,636 KB
testcase_13 AC 275 ms
52,476 KB
testcase_14 AC 272 ms
52,752 KB
testcase_15 AC 278 ms
52,724 KB
testcase_16 AC 268 ms
52,756 KB
testcase_17 AC 270 ms
52,880 KB
testcase_18 AC 267 ms
52,584 KB
testcase_19 AC 270 ms
52,784 KB
testcase_20 AC 259 ms
52,688 KB
testcase_21 AC 260 ms
52,688 KB
testcase_22 AC 265 ms
53,012 KB
testcase_23 AC 263 ms
52,580 KB
testcase_24 AC 260 ms
52,632 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:21:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

package net.ipipip0129.kotlin.yukicoder

import kotlin.math.pow
import kotlin.math.sqrt

private fun checkNumPrime(num: Long): Boolean {
    when {
        num < 2L -> return false
        num == 2L -> return true
        num % 2L == 0L -> return false
        else -> {
            val sqrtNum = sqrt(num.toDouble())
            for (i in 3..sqrtNum.toLong() step 2) {
                if (num % i == 0L) return false
            }
        }
    }
    return true
}

fun main(args: Array<String>) {
    val posList = readLine()!!.split(" ").map { it.toLong() }
    var maxX = 10.0.pow(1333).toLong()
    var maxY = 10.0.pow(1333).toLong()

    if (checkNumPrime(posList[0]) && checkNumPrime(posList[1])) {
        println("Second")
        return
    }

    for (i in posList[0] + 1 until 10.0.pow(1333).toLong()) {
        if (checkNumPrime(i)) {
            maxY = i
            break
        }
    }

    for (i in posList[1] + 1 until 10.0.pow(1333).toLong()) {
        if (checkNumPrime(i)) {
            maxX = i
            break
        }
    }

    var isFirst = true
    var npX = posList[1]
    var npY = posList[0]
    while (true) {
        if (npX < maxX - 1) {
            npX += 1
        } else if (npY < maxY - 1) {
            npY += 1
        } else {
            break
        }

        isFirst = !isFirst
    }
    if (!isFirst) {
        println("First")
    } else {
        println("Second")
    }
}
0