mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-25 06:31:59 +00:00
D - 2-variable Function
https://atcoder.jp/contests/abc246/submissions/30655016
This commit is contained in:
parent
262d2c01f9
commit
fdaa6957c8
31
AtCoder/ABC246/D/D.cpp
Normal file
31
AtCoder/ABC246/D/D.cpp
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user