0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 16:38:47 +00:00

D - 2-variable Function

https://atcoder.jp/contests/abc246/submissions/30655016
This commit is contained in:
Baoshuo Ren 2022-04-02 20:54:08 +08:00
parent 262d2c01f9
commit fdaa6957c8
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

31
AtCoder/ABC246/D/D.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <cmath>
#include <iostream>
#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;
}