#include<stdio.h>
#include<string.h>
int main()
{
int i,j,k,n;
int a[20];
int num1[350],num2[350];
memset(num1,0,sizeof(num1));
memset(num2,0,sizeof(num2));
for(i=1;i<=17;i++)
a[i]=i*i;
for(i=0;i<=300;i++)
{
num1[i]=1;
num2[i]=0;
}
for(i=2;i<=17;i++)
{
for(j=0;j<=300;j++)
for(k=0;k+j<=300;k+=a[i])
num2[k+j]+=num1[j];
for(j=0;j<=300;j++)
{
num1[j]=num2[j];
num2[j]=0;
}
}
while(scanf("%d",&n)&&n)
printf("%d\n",num1[n]);
return 0;
}
HDU 1398
最新推荐文章于 2019-09-30 17:48:40 发布