結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
50,040 KB
testcase_01 AC 298 ms
50,076 KB
testcase_02 AC 296 ms
49,948 KB
testcase_03 AC 299 ms
50,092 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 297 ms
50,124 KB
testcase_07 AC 298 ms
49,892 KB
testcase_08 AC 302 ms
49,964 KB
testcase_09 AC 296 ms
50,164 KB
testcase_10 AC 294 ms
49,884 KB
testcase_11 AC 296 ms
49,968 KB
testcase_12 AC 302 ms
50,248 KB
testcase_13 AC 296 ms
49,968 KB
testcase_14 AC 296 ms
50,092 KB
testcase_15 AC 298 ms
49,936 KB
testcase_16 AC 296 ms
50,016 KB
testcase_17 AC 301 ms
50,080 KB
testcase_18 AC 302 ms
50,132 KB
testcase_19 AC 296 ms
50,172 KB
testcase_20 AC 304 ms
50,188 KB
testcase_21 AC 295 ms
49,896 KB
testcase_22 AC 296 ms
50,176 KB
testcase_23 AC 297 ms
50,180 KB
testcase_24 AC 296 ms
49,932 KB
testcase_25 AC 300 ms
49,932 KB
testcase_26 AC 298 ms
50,244 KB
testcase_27 AC 298 ms
50,176 KB
testcase_28 AC 302 ms
50,060 KB
testcase_29 AC 296 ms
49,968 KB
testcase_30 AC 295 ms
50,176 KB
testcase_31 AC 299 ms
50,168 KB
testcase_32 AC 299 ms
50,172 KB
testcase_33 AC 300 ms
49,968 KB
testcase_34 AC 298 ms
50,156 KB
testcase_35 AC 299 ms
50,068 KB
testcase_36 AC 305 ms
49,948 KB
testcase_37 AC 299 ms
49,964 KB
testcase_38 AC 294 ms
49,964 KB
testcase_39 AC 299 ms
50,024 KB
testcase_40 AC 301 ms
50,080 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 0..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