結果

問題 No.1664 Unstable f(n)
ユーザー ygd.ygd.
提出日時 2021-09-03 21:35:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 70,400 KB
最終ジャッジ日時 2024-05-09 02:15:24
合計ジャッジ時間 3,138 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,992 KB
testcase_01 AC 43 ms
64,384 KB
testcase_02 AC 41 ms
61,184 KB
testcase_03 AC 35 ms
52,352 KB
testcase_04 AC 35 ms
52,352 KB
testcase_05 AC 35 ms
52,864 KB
testcase_06 AC 38 ms
52,480 KB
testcase_07 AC 36 ms
52,608 KB
testcase_08 AC 36 ms
52,608 KB
testcase_09 AC 35 ms
52,608 KB
testcase_10 AC 37 ms
52,224 KB
testcase_11 AC 43 ms
67,584 KB
testcase_12 AC 46 ms
69,888 KB
testcase_13 AC 47 ms
70,016 KB
testcase_14 AC 47 ms
69,504 KB
testcase_15 AC 45 ms
68,352 KB
testcase_16 AC 46 ms
69,376 KB
testcase_17 AC 48 ms
69,760 KB
testcase_18 AC 47 ms
69,632 KB
testcase_19 AC 47 ms
70,400 KB
testcase_20 AC 47 ms
69,376 KB
testcase_21 AC 43 ms
63,232 KB
testcase_22 AC 42 ms
63,104 KB
testcase_23 AC 42 ms
63,616 KB
testcase_24 AC 42 ms
63,232 KB
testcase_25 AC 42 ms
63,232 KB
testcase_26 AC 38 ms
55,296 KB
testcase_27 AC 38 ms
54,784 KB
testcase_28 AC 37 ms
55,188 KB
testcase_29 AC 41 ms
54,784 KB
testcase_30 AC 40 ms
55,168 KB
testcase_31 AC 42 ms
62,592 KB
testcase_32 AC 45 ms
66,048 KB
testcase_33 AC 42 ms
64,256 KB
testcase_34 AC 41 ms
61,952 KB
testcase_35 AC 46 ms
69,504 KB
testcase_36 AC 43 ms
63,488 KB
testcase_37 AC 45 ms
67,584 KB
testcase_38 AC 38 ms
53,888 KB
testcase_39 AC 44 ms
65,664 KB
testcase_40 AC 48 ms
67,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

import math

def main():
    n = int(input())
    ans = n
    j = 1
    while True:
        i = solve(j,n)
        k = n - pow(i, j)
        ans = min(ans, i+j+k)
        j += 1
        #print(i,j,k)
        if i == 1:
            break
    print(ans)

def solve(j,n):
    #i ** j <= nとなる最大のi
    ok = 0
    ng = pow(10,18)
    while abs(ok - ng) > 1:
        mid = (ok+ng)//2
        if pow(mid, j) <= n:
            ok = mid
        else:
            ng = mid
    return ok


if __name__ == "__main__":
    main()
0