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\n",dp[n]);
}
return 0;
}

 

posted @ 2014-11-25 22:09  立刻行动  阅读(80)  评论(0编辑  收藏  举报