結果

問題 No.136 Yet Another GCD Problem
ユーザー バカらっくバカらっく
提出日時 2019-10-03 16:10:51
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 602 bytes
コンパイル時間 13,166 ms
コンパイル使用メモリ 439,684 KB
実行使用メモリ 60,552 KB
最終ジャッジ日時 2024-04-14 09:27:50
合計ジャッジ時間 27,798 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 324 ms
60,456 KB
testcase_01 AC 308 ms
56,872 KB
testcase_02 AC 323 ms
60,508 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 324 ms
60,340 KB
testcase_09 AC 312 ms
56,912 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 308 ms
57,004 KB
testcase_24 WA -
testcase_25 AC 308 ms
56,964 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 330 ms
60,312 KB
testcase_32 WA -
testcase_33 AC 314 ms
56,892 KB
testcase_34 AC 322 ms
60,336 KB
testcase_35 AC 307 ms
57,064 KB
testcase_36 AC 317 ms
56,860 KB
testcase_37 AC 328 ms
60,348 KB
testcase_38 AC 309 ms
57,064 KB
testcase_39 AC 328 ms
60,444 KB
testcase_40 AC 308 ms
56,892 KB
testcase_41 AC 309 ms
56,848 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 >= n) {
        println(1)
        return
    }
    if(k == 1L) {
        println(n)
        return
    }

    val maxIndex = Math.sqrt(n.toDouble()).toLong()
    var ans = 0L
    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(tmp >= k) {
                ans = Math.max(ans, j)
            }
        }
    }
    println(ans)
}

0