結果

問題 No.1176 少ない質問
ユーザー yudedakoyudedako
提出日時 2020-08-22 09:49:39
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 382 ms / 1,000 ms
コード長 444 bytes
コンパイル時間 13,664 ms
コンパイル使用メモリ 437,828 KB
実行使用メモリ 52,936 KB
最終ジャッジ日時 2024-04-23 07:00:21
合計ジャッジ時間 22,147 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 371 ms
50,964 KB
testcase_01 AC 365 ms
51,084 KB
testcase_02 AC 382 ms
52,936 KB
testcase_03 AC 374 ms
51,152 KB
testcase_04 AC 368 ms
50,952 KB
testcase_05 AC 379 ms
50,916 KB
testcase_06 AC 367 ms
50,940 KB
testcase_07 AC 375 ms
51,036 KB
testcase_08 AC 363 ms
51,152 KB
testcase_09 AC 366 ms
51,020 KB
testcase_10 AC 363 ms
50,872 KB
testcase_11 AC 360 ms
51,168 KB
testcase_12 AC 369 ms
51,044 KB
testcase_13 AC 363 ms
50,952 KB
testcase_14 AC 371 ms
50,996 KB
testcase_15 AC 367 ms
51,028 KB
testcase_16 AC 374 ms
50,920 KB
testcase_17 AC 371 ms
51,288 KB
testcase_18 AC 365 ms
51,040 KB
testcase_19 AC 371 ms
51,032 KB
testcase_20 AC 329 ms
51,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import kotlin.math.min

const val MOD = 1000000007L

fun main() {
    val a = readLine()!!.trim().toLong()
    var minScore = Long.MAX_VALUE
    for (n in 2 .. min(a, 1000000)) {
        var m = 0
        var s = a
        var r = 0L
        while (s > 0) {
            r += s % n
            s /= n
            ++m
        }
        if (r == 1L) {
            --m
        }
        minScore = min(minScore, m * n)
    }
    println(minScore)
}
0