結果

問題 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
コンパイル時間 479 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 71,036 KB
最終ジャッジ日時 2024-12-15 10:44:02
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

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