結果
| 問題 |
No.1664 Unstable f(n)
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-05-20 00:21:51 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 997 bytes |
| コンパイル時間 | 4,118 ms |
| コンパイル使用メモリ | 273,964 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-05-20 00:21:57 |
| 合計ジャッジ時間 | 4,644 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
constexpr ll INF = LLONG_MAX;
inline ll saturating_pow(ll a, ll b) {
ll res = 1;
rep(_, b) {
if (res > INF / a) return INF;
res *= a;
}
return res;
}
inline ll floor_root(ll n, ll k) {
ll about = min((long double) INF, powl(n, 1.0l / k));
while (about > 1 && saturating_pow(about, k) > n) --about;
while (saturating_pow(about + 1, k) <= n) ++about;
return about;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
ll n;
cin >> n;
if (n <= 2) {
cout << n << '\n';
return 0;
}
ll ans = n + 1;
for (int j = 2; j <= 60; ++j) {
ll i = floor_root(n, j);
ll k = n - saturating_pow(i, j);
if (k < 0) continue;
Debug(i, j, k);
ans = min(ans, i + j + k);
}
cout << ans << '\n';
return 0;
}
a01sa01to