简单动归,,
完全背包类型的吧 ,,,,
代码如下;
#include <cstdio> #include <cstring> #define M 10005 int coin[21] = {1 ,8 ,27 ,64 ,125 ,216 ,343 ,512 ,729 ,1000 ,1331 ,1728 ,2197 ,2744 , 3375 ,4096,4913 ,5832 ,6859 ,8000 ,9261}; long long dp[M]; int n; int main () { dp[0] = 1; for(int i = 0; i < 21; i++) { int v = coin[i]; for(int j = v; j < M; j++) dp[j]+=dp[j-v]; } while(~scanf("%d",&n)) { printf("%lld\n",dp[n]); } return 0; }