結果
| 問題 | No.1664 Unstable f(n) |
| コンテスト | |
| ユーザー |
koheijkt
|
| 提出日時 | 2026-04-22 18:53:44 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 544 bytes |
| 記録 | |
| コンパイル時間 | 316 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 52,608 KB |
| 最終ジャッジ日時 | 2026-04-22 18:53:48 |
| 合計ジャッジ時間 | 2,718 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
N = int(input())
# k 乗根
def sqrt(n: int, k = 2):
l = k - 1
if not n: return 0
y = 1 << (n.bit_length() + l) // k
x = y + 1
while y < x:
x = y
y = (l * x + n // (x ** l)) // k
return x
# n == i**j + k
# 2**60 = 10**18 なので j の上限は 60 くらい
# n == 1**0 + (n - 1)
ans = N
flag = False
for j in range(1, 62):
i = sqrt(N, j)
if i == 1:
j = 0
flag = True
k = N - i**j
X = i + j + k
if X < ans:
ans = X
if flag:
break
print(ans)
koheijkt