結果

問題 No.1664 Unstable f(n)
ユーザー 👑 箱星箱星
提出日時 2021-09-03 21:37:07
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,424 bytes
コンパイル時間 13,720 ms
コンパイル使用メモリ 456,132 KB
実行使用メモリ 58,656 KB
最終ジャッジ日時 2024-05-09 02:22:44
合計ジャッジ時間 27,501 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 299 ms
50,168 KB
testcase_01 AC 295 ms
49,992 KB
testcase_02 AC 296 ms
50,068 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 301 ms
50,136 KB
testcase_07 AC 295 ms
49,880 KB
testcase_08 AC 297 ms
49,984 KB
testcase_09 AC 301 ms
49,960 KB
testcase_10 AC 304 ms
49,892 KB
testcase_11 AC 305 ms
50,092 KB
testcase_12 AC 299 ms
50,116 KB
testcase_13 AC 300 ms
50,076 KB
testcase_14 AC 302 ms
50,144 KB
testcase_15 AC 296 ms
49,972 KB
testcase_16 AC 298 ms
49,948 KB
testcase_17 AC 327 ms
50,072 KB
testcase_18 AC 301 ms
50,024 KB
testcase_19 AC 303 ms
50,084 KB
testcase_20 AC 304 ms
50,108 KB
testcase_21 AC 304 ms
50,224 KB
testcase_22 AC 302 ms
50,140 KB
testcase_23 AC 301 ms
50,148 KB
testcase_24 AC 299 ms
49,980 KB
testcase_25 AC 307 ms
49,928 KB
testcase_26 AC 302 ms
50,168 KB
testcase_27 AC 302 ms
50,076 KB
testcase_28 AC 296 ms
50,136 KB
testcase_29 AC 294 ms
50,180 KB
testcase_30 AC 296 ms
50,148 KB
testcase_31 AC 298 ms
50,084 KB
testcase_32 AC 296 ms
49,960 KB
testcase_33 AC 300 ms
50,248 KB
testcase_34 AC 296 ms
49,920 KB
testcase_35 AC 297 ms
50,176 KB
testcase_36 AC 297 ms
50,068 KB
testcase_37 AC 299 ms
49,844 KB
testcase_38 AC 297 ms
50,172 KB
testcase_39 AC 298 ms
50,060 KB
testcase_40 AC 298 ms
50,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val n = nextLong()
    var min = Long.MAX_VALUE
    for (j in 1..60) {
        var l = 1L
        var r = n + 1
        outer@while (r - l > 1) {
            val mid = (l + r) / 2
            var pow = 1L
            for (_i in 0 until j) {
                if (pow > n / mid) {
                    r = mid
                    continue@outer
                }
                pow *= mid
            }
            if (pow > n) {
                r = mid
            } else {
                l = mid
            }
        }
        val i = l
        val k = n - LongArray(j) { i }.fold(1L, Long::times)
        min = min(min, i + j + k)
    }
    println(min)
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", 1.shl(26))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0