首页 > 代码库 > hdu 1398 Square Coins

hdu 1398 Square Coins

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1398

类似hdu 1284  hdu1028

code:

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>

using namespace std;

int main()
{
    int n,i,j;
    int dp[310];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(i=1;i<=sqrt(310);i++)
    {
        for(j=i*i;j<=310;j++)
        {
            dp[j]+=dp[j-i*i];
        }
    }
    while(scanf("%d",&n)==1&&n)
    {

        printf("%d\n",dp[n]);
    }
    return 0;
}