結果

問題 No.726 Tree Game
ユーザー Pump0129Pump0129
提出日時 2018-08-24 21:59:36
言語 Kotlin
(1.9.10)
結果
WA  
実行時間 -
コード長 1,420 bytes
コンパイル時間 12,765 ms
コンパイル使用メモリ 418,836 KB
実行使用メモリ 53,472 KB
最終ジャッジ日時 2023-08-13 00:18:01
合計ジャッジ時間 21,660 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 293 ms
52,848 KB
testcase_01 AC 295 ms
52,904 KB
testcase_02 AC 292 ms
52,796 KB
testcase_03 WA -
testcase_04 AC 294 ms
53,084 KB
testcase_05 AC 296 ms
52,868 KB
testcase_06 AC 298 ms
52,824 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 293 ms
52,868 KB
testcase_11 WA -
testcase_12 AC 292 ms
53,132 KB
testcase_13 WA -
testcase_14 AC 290 ms
52,956 KB
testcase_15 AC 291 ms
52,860 KB
testcase_16 AC 291 ms
52,912 KB
testcase_17 AC 294 ms
52,980 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 295 ms
52,904 KB
testcase_21 AC 293 ms
53,224 KB
testcase_22 WA -
testcase_23 AC 298 ms
52,888 KB
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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()
    for (i in posList[0] until 10.0.pow(1333).toLong()) {
        if (checkNumPrime(i)) {
            maxY = i
            break
        }
    }

    for (i in posList[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 && npY < maxY) {
            if (npX < maxX) {
                npX += 1
            } else if (npY < maxY) {
                npY += 1
            }
        } else {
            break
        }
        isFirst = !isFirst
    }
    if (isFirst) {
        println("First")
    } else {
        println("Second")
    }
}
0