結果

問題 No.36 素数が嫌い!
ユーザー バカらっくバカらっく
提出日時 2019-09-07 19:29:06
言語 Kotlin
(1.9.23)
結果
TLE  
実行時間 -
コード長 602 bytes
コンパイル時間 11,310 ms
コンパイル使用メモリ 411,092 KB
実行使用メモリ 54,564 KB
最終ジャッジ日時 2023-09-09 08:58:51
合計ジャッジ時間 24,646 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 251 ms
50,004 KB
testcase_01 AC 322 ms
52,412 KB
testcase_02 AC 253 ms
50,796 KB
testcase_03 AC 253 ms
50,096 KB
testcase_04 AC 251 ms
50,052 KB
testcase_05 AC 4,687 ms
50,248 KB
testcase_06 AC 254 ms
50,300 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