結果

問題 No.36 素数が嫌い!
ユーザー バカらっくバカらっく
提出日時 2019-09-07 19:26:06
言語 Kotlin
(1.9.10)
結果
WA  
実行時間 -
コード長 601 bytes
コンパイル時間 12,730 ms
コンパイル使用メモリ 414,332 KB
実行使用メモリ 93,452 KB
最終ジャッジ日時 2023-09-09 08:53:27
合計ジャッジ時間 26,303 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 264 ms
93,452 KB
testcase_01 WA -
testcase_02 AC 270 ms
50,136 KB
testcase_03 AC 270 ms
50,184 KB
testcase_04 AC 270 ms
50,636 KB
testcase_05 AC 4,719 ms
50,252 KB
testcase_06 AC 271 ms
50,240 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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) {
        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