結果

問題 No.36 素数が嫌い!
ユーザー バカらっくバカらっく
提出日時 2019-09-07 19:32:10
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 368 ms / 5,000 ms
コード長 631 bytes
コンパイル時間 10,929 ms
コンパイル使用メモリ 418,624 KB
実行使用メモリ 52,084 KB
最終ジャッジ日時 2023-09-09 09:02:19
合計ジャッジ時間 21,463 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 251 ms
50,312 KB
testcase_01 AC 256 ms
50,636 KB
testcase_02 AC 250 ms
50,252 KB
testcase_03 AC 248 ms
50,272 KB
testcase_04 AC 266 ms
50,392 KB
testcase_05 AC 254 ms
50,248 KB
testcase_06 AC 254 ms
50,332 KB
testcase_07 AC 254 ms
52,084 KB
testcase_08 AC 252 ms
50,508 KB
testcase_09 AC 252 ms
50,272 KB
testcase_10 AC 250 ms
50,432 KB
testcase_11 AC 291 ms
50,444 KB
testcase_12 AC 368 ms
50,340 KB
testcase_13 AC 367 ms
50,176 KB
testcase_14 AC 252 ms
50,180 KB
testcase_15 AC 250 ms
50,364 KB
testcase_16 AC 248 ms
50,156 KB
testcase_17 AC 250 ms
50,072 KB
testcase_18 AC 249 ms
49,976 KB
testcase_19 AC 253 ms
50,260 KB
testcase_20 AC 260 ms
50,204 KB
testcase_21 AC 251 ms
50,140 KB
testcase_22 AC 250 ms
50,172 KB
testcase_23 AC 248 ms
50,316 KB
testcase_24 AC 269 ms
50,360 KB
testcase_25 AC 249 ms
50,644 KB
testcase_26 AC 328 ms
50,016 KB
testcase_27 AC 354 ms
50,188 KB
testcase_28 AC 320 ms
50,356 KB
testcase_29 AC 362 ms
50,116 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 >= 2 && target > 1) {
            return true
        }
    }
    return false
}
0