結果

問題 No.36 素数が嫌い!
ユーザー バカらっくバカらっく
提出日時 2019-09-07 19:31:29
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 617 bytes
コンパイル時間 13,264 ms
コンパイル使用メモリ 413,036 KB
実行使用メモリ 50,836 KB
最終ジャッジ日時 2023-09-09 09:00:53
合計ジャッジ時間 23,908 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 265 ms
50,272 KB
testcase_01 AC 343 ms
50,396 KB
testcase_02 AC 267 ms
50,232 KB
testcase_03 AC 266 ms
50,336 KB
testcase_04 AC 266 ms
50,388 KB
testcase_05 AC 268 ms
50,392 KB
testcase_06 AC 270 ms
50,268 KB
testcase_07 AC 270 ms
50,304 KB
testcase_08 AC 266 ms
50,376 KB
testcase_09 AC 267 ms
50,252 KB
testcase_10 WA -
testcase_11 AC 313 ms
50,320 KB
testcase_12 AC 383 ms
50,236 KB
testcase_13 AC 387 ms
50,412 KB
testcase_14 AC 270 ms
50,272 KB
testcase_15 AC 267 ms
50,348 KB
testcase_16 AC 270 ms
50,732 KB
testcase_17 AC 268 ms
50,344 KB
testcase_18 AC 270 ms
50,384 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 293 ms
50,364 KB
testcase_25 AC 265 ms
50,232 KB
testcase_26 AC 336 ms
50,364 KB
testcase_27 AC 364 ms
50,568 KB
testcase_28 AC 339 ms
50,360 KB
testcase_29 AC 377 ms
50,412 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
         ^

ソースコード

diff #

fun main(arr:Array<String>) {
    val num = readLine()!!.toLong()
    val ans = if(canUse(num)) "YES" else "NO"
    println(ans)
}

fun canUse(num:Long):Boolean {
    var cur = 2.toLong()
    var target = num;
    var ans = 0
    while (target > 1.toLong() && cur <= target && cur*cur<num) {
        var cnt = 0
        while (target % cur == 0.toLong()) {
            cnt++;
            target = target / cur
            if(cnt >= 2 && target > 1) {
                return true
            }
        }
        ans += cnt
        cur++
        if(ans >= 3) {
            return true
        }
    }
    return false
}
0