Skip to content

Commit

Permalink
Add 22825.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Jul 20, 2024
1 parent 1b13737 commit 38d921a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 22xxx/22825.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <algorithm>
#include <iostream>
using namespace std;

inline int cube(int n) {
return n * n * n;
}

inline int cube_root(int n) {
int x = 0;
while (x * x * x <= n) x++;
return --x;
}

bool solve(void) {
int n; cin >> n;
if (n == 0) return false;

int ans = cube(n);
for (int i=1; i<n; i++) {
int x = cube(n) - cube(i);
ans = min(ans, x - cube(cube_root(x)));
}
cout << ans << "\n";

return true;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

while (solve());
return 0;
}

0 comments on commit 38d921a

Please sign in to comment.