0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-05 13:38:47 +00:00
OI-codes/Luogu/P1679/P1679.cpp

35 lines
522 B
C++
Raw Normal View History

2020-10-29 13:57:30 +00:00
#include <bits/stdc++.h>
using namespace std;
int n, ans = 999999;
void dfs(int cnt, int k, int last) {
if (k > ans) {
return;
}
if (cnt > n) {
return;
}
if (cnt == n) {
ans = min(ans, k);
return;
}
int i = last;
2021-11-19 09:01:13 +00:00
while (i * i * i * i <= n - cnt) {
2020-10-29 13:57:30 +00:00
i++;
}
while (i >= last) {
dfs(cnt + i * i * i * i, k + 1, i);
i--;
}
return;
}
int main() {
cin >> n;
dfs(0, 0, 1);
cout << ans << endl;
return 0;
}