結果

問題 No.1664 Unstable f(n)
ユーザー netyo715
提出日時 2021-07-29 21:28:41
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 479 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-12-15 08:46:57
合計ジャッジ時間 2,439 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import log2
N = int(input())

# 1^0+0=1
"""if N==1:
    print(1)
    exit()
"""
ans = 10**10

def is_ok(arg, j):
    return pow(arg, j) <= N

def meguru_bisect(ng, ok, j):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, j):
            ok = mid
        else:
            ng = mid
    return ok

for j in range(int(log2(N))+1):
    i = meguru_bisect(N, 1, j)
    k = N-pow(i, j)
    # print(i, j, k)
    ans = min(ans, i+j+k)

print(ans)
0