結果
| 問題 | No.1664 Unstable f(n) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-04 02:55:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 612 bytes |
| コンパイル時間 | 2,179 ms |
| コンパイル使用メモリ | 192,212 KB |
| 最終ジャッジ日時 | 2025-01-24 07:34:35 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using std::cin;
using std::cout;
using std::vector;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
ll mpow(ll x, ll y) {
ll res = 1;
while (y) {
if (y & 1) res *= x;
x *= x;
y >>= 1;
}
return res;
}
void chmin(ll &x, ll y) { if (x > y) x = y; }
int main() {
ll n;
cin >> n;
ll ans = n;
for (int j = 1; j <= std::__lg(n); ++j) {
ll i = pow(n, 1.0 / j);
while (pow(i + 1, j) <= n) i++;
ll k = n - mpow(i, j);
ll now = i + j + k;
chmin(ans, now);
}
cout << ans << '\n';
return 0;
}