题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1398
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; }
hdu 1398 Square Coins,布布扣,bubuko.com
原文地址:http://blog.csdn.net/u010304217/article/details/38374553