mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 18:11:59 +00:00
P1679 神奇的四次方数
R40788402
This commit is contained in:
parent
c2fe814e8a
commit
5bbc2ca861
34
problem/P1679/P1679.cpp
Normal file
34
problem/P1679/P1679.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#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;
|
||||
while (i*i*i*i <= n - cnt) {
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user