# include <stdio.h> # include <algorithm> # include <string.h> # include <iostream> using namespace std; int main() { int n,i,j,k; int c1[310],c2[310]; while(~scanf("%d",&n),n) { for(i=0;i<=n;i++) { c1[i]=1; c2[i]=0; } for(i=2;i<=17;i++)///指数系数 { for(j=0;j<=n;j++) { for(k=0;k+j<=n;k+=i*i)///关键 { c2[k+j]+=c1[j]; } } for(j=0;j<=n;j++) { c1[j]=c2[j]; c2[j]=0; } } printf("%d\n",c1[n]); } return 0; }
原文地址:http://blog.csdn.net/lp_opai/article/details/39754127