0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 02:28:47 +00:00
OI-codes/AtCoder/ABC246/D/D.cpp

32 lines
562 B
C++

#include <iostream>
#include <cmath>
#include <limits>
using std::cin;
using std::cout;
const char endl = '\n';
long long n, a, b, ans = std::numeric_limits<long long>::max();
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
if (!n) {
cout << 0 << endl;
exit(0);
}
while (std::pow(a, 3) * 4 < n) b = ++a;
while (b) {
while (b && (a + b - 1) * (a * a + (b - 1) * (b - 1)) >= n) b--;
ans = std::min(ans, (a + b) * (a * a + b * b));
a++;
}
cout << ans << endl;
return 0;
}