#include <iostream>
#include <cstring>
using namespace std;
const int MAX = 301;
int n,a[MAX],b[MAX],i,j,k,v[18];
int main()
{
for (i=1;i<=17;i++)
v[i]=i*i;
while ((cin>>n)&&n>0)
{
memset(a,0,sizeof(a));
a[0]=1;
for (i=1;i<=17;i++)
{
memset(b,0,sizeof(b));
for (j=0;j*v[i]<=n;j++)
for (k=0;k+j*v[i]<=n;k++)
b[k+j*v[i]]+=a[k];
memcpy(a,b,sizeof(b));
}
cout<<a[n]<<endl;
}
return 0;
}
hdu1398 Square Coins 母函数的无上限形式
最新推荐文章于 2021-04-16 04:42:29 发布