結果

問題 No.136 Yet Another GCD Problem
ユーザー バカらっくバカらっく
提出日時 2019-10-03 16:14:40
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 329 ms / 5,000 ms
コード長 546 bytes
コンパイル時間 12,444 ms
コンパイル使用メモリ 439,432 KB
実行使用メモリ 60,556 KB
最終ジャッジ日時 2024-04-14 09:29:56
合計ジャッジ時間 26,878 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 325 ms
60,312 KB
testcase_01 AC 321 ms
60,380 KB
testcase_02 AC 328 ms
60,464 KB
testcase_03 AC 324 ms
60,392 KB
testcase_04 AC 324 ms
60,368 KB
testcase_05 AC 326 ms
60,372 KB
testcase_06 AC 325 ms
60,416 KB
testcase_07 AC 322 ms
60,508 KB
testcase_08 AC 327 ms
60,412 KB
testcase_09 AC 321 ms
60,460 KB
testcase_10 AC 325 ms
60,296 KB
testcase_11 AC 321 ms
60,300 KB
testcase_12 AC 329 ms
60,472 KB
testcase_13 AC 326 ms
60,268 KB
testcase_14 AC 327 ms
60,312 KB
testcase_15 AC 324 ms
60,320 KB
testcase_16 AC 323 ms
60,388 KB
testcase_17 AC 328 ms
60,344 KB
testcase_18 AC 323 ms
60,368 KB
testcase_19 AC 326 ms
60,436 KB
testcase_20 AC 323 ms
60,404 KB
testcase_21 AC 322 ms
60,372 KB
testcase_22 AC 322 ms
60,332 KB
testcase_23 AC 326 ms
60,528 KB
testcase_24 AC 322 ms
60,348 KB
testcase_25 AC 322 ms
60,556 KB
testcase_26 AC 326 ms
60,304 KB
testcase_27 AC 321 ms
60,516 KB
testcase_28 AC 323 ms
60,376 KB
testcase_29 AC 329 ms
60,268 KB
testcase_30 AC 322 ms
60,312 KB
testcase_31 AC 321 ms
60,392 KB
testcase_32 AC 326 ms
60,356 KB
testcase_33 AC 325 ms
60,276 KB
testcase_34 AC 325 ms
60,396 KB
testcase_35 AC 324 ms
60,340 KB
testcase_36 AC 327 ms
60,392 KB
testcase_37 AC 325 ms
60,164 KB
testcase_38 AC 324 ms
60,304 KB
testcase_39 AC 326 ms
60,520 KB
testcase_40 AC 326 ms
60,344 KB
testcase_41 AC 324 ms
60,364 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
         ^

ソースコード

diff #

fun main(args:Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }

    if(k == 1L) {
        println(n)
        return
    }

    val maxIndex = Math.sqrt(n.toDouble()).toLong()
    var ans = 1L
    for(i in (1..maxIndex)) {
        if(n % i != 0L) {
            continue
        }
        val num = (n/i).let { listOf(it, n / it) }.sortedDescending()
        for(j in num) {
            val tmp = n / j
            if(2 <= tmp) {
                ans = Math.max(ans, j)
            }
        }
    }
    println(ans)
}

0