結果
問題 | No.1664 Unstable f(n) |
ユーザー |
![]() |
提出日時 | 2021-09-03 21:35:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 864 bytes |
コンパイル時間 | 347 ms |
コンパイル使用メモリ | 82,528 KB |
実行使用メモリ | 64,468 KB |
最終ジャッジ日時 | 2024-12-15 10:41:36 |
合計ジャッジ時間 | 3,326 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import sys from operator import itemgetter stdin=sys.stdin sys.setrecursionlimit(10 ** 8) ip=lambda: int(sp()) fp=lambda: float(sp()) lp=lambda:list(map(int,stdin.readline().split())) sp=lambda:stdin.readline().rstrip() Yp=lambda:print('Yes') Np=lambda:print('No') inf = 1 << 60 eps = 1e-9 sortkey = itemgetter(0) n = ip() ans = inf for i in range(60): if i == 0: ans = min(ans, n) else: ok = 1 ng = inf while abs(ok - ng) > 1: mid = (ok + ng) // 2 temp = 1 now = 0 while now < i: temp *= mid if temp > n: break now += 1 if now == i: ok = mid else: ng = mid res = n - ok ** i + ok + i ans = min(ans, res) print(ans)