HDU-1028-Ignatius and the Princess III

题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=1028

dp  就是背包的硬币问题。可以类似 HDU 1284

#include<stdio.h>
#include<string.h>

int main(void)
{
int i,j,k,n;
int dp[125];
memset(dp,0,sizeof(dp));
dp[0]=1;
for(i=1;i<=120;i++)
{
for(j=i;j<=120;j++)
{
dp[j]=dp[j]+dp[j-i];
}
}
while(scanf("%d",&n)==1)
{
printf("%d ",dp[n]);
}
return 0;
}

原文地址:https://www.cnblogs.com/liudehao/p/4122065.html