Title Description
In your help, v God finally help students find the most suitable college, the next step is to inform the students. Responsible for liaison network dm students are in class, so they found God v dm students may dm students are busy studying an interesting math problem, in order to please dm mountains, v God but to ask you to help solve the problem asks.
Description Title: decomposition of an integer m and the number n in the form of the fourth power, minimum requirements n. For example, m = 706,706 = 5 ^ 4 + 3 ^ 4, then n = 2.
Input Format
Row, an integer m.
Output Format
Row, an integer n.
Sample input and output
Input # 1
706
Output # 1
2
Description / Tips
Data range: For 30% of the data, m <= 5000; data for 100%, m <= 100,000
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<queue> using namespace std; int f[200001],w[200001],n=18,m; using namespace std; //全局变量部分 int main() { memset(f,0xf,sizeof(f)); f[0]=0;cin>>m; //初始化数据 for(int i=1;i<=n;i++) w[i]=i*i*i*i; for(int i=1;i<=n;i++) //完全背包 for(int v=w[i];v<=m;++v) if(f[v]>f[v-w[i]]+1) f[v]=f[v-w[i]]+1; cout<<f[m]; }