結果

問題 No.1664 Unstable f(n)
ユーザー ygd.ygd.
提出日時 2021-09-03 21:35:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 75,504 KB
最終ジャッジ日時 2023-08-21 20:13:31
合計ジャッジ時間 5,122 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,260 KB
testcase_01 AC 77 ms
75,256 KB
testcase_02 AC 76 ms
75,332 KB
testcase_03 AC 70 ms
70,980 KB
testcase_04 AC 71 ms
70,972 KB
testcase_05 AC 72 ms
71,172 KB
testcase_06 AC 72 ms
71,232 KB
testcase_07 AC 70 ms
70,944 KB
testcase_08 AC 71 ms
71,104 KB
testcase_09 AC 71 ms
71,228 KB
testcase_10 AC 71 ms
71,116 KB
testcase_11 AC 79 ms
75,204 KB
testcase_12 AC 80 ms
75,088 KB
testcase_13 AC 82 ms
75,240 KB
testcase_14 AC 81 ms
75,080 KB
testcase_15 AC 80 ms
75,240 KB
testcase_16 AC 80 ms
75,128 KB
testcase_17 AC 82 ms
75,244 KB
testcase_18 AC 83 ms
75,356 KB
testcase_19 AC 80 ms
75,236 KB
testcase_20 AC 80 ms
75,128 KB
testcase_21 AC 78 ms
75,380 KB
testcase_22 AC 77 ms
75,232 KB
testcase_23 AC 78 ms
75,252 KB
testcase_24 AC 78 ms
75,388 KB
testcase_25 AC 76 ms
75,300 KB
testcase_26 AC 72 ms
70,984 KB
testcase_27 AC 72 ms
71,096 KB
testcase_28 AC 72 ms
70,844 KB
testcase_29 AC 73 ms
71,260 KB
testcase_30 AC 73 ms
70,780 KB
testcase_31 AC 78 ms
75,236 KB
testcase_32 AC 80 ms
75,396 KB
testcase_33 AC 81 ms
75,240 KB
testcase_34 AC 77 ms
75,080 KB
testcase_35 AC 80 ms
75,504 KB
testcase_36 AC 76 ms
75,232 KB
testcase_37 AC 80 ms
75,128 KB
testcase_38 AC 75 ms
71,084 KB
testcase_39 AC 79 ms
75,252 KB
testcase_40 AC 79 ms
75,456 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