http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2777&cid=1219
这题不会,看了别人的代码
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int dp[];
int main()
{
int n,i,j;
int w[]= {,,,};
memset(dp,,sizeof(dp));
dp[]=;
for(i=; i<=; i++)
{
for(j=w[i]; j<=; j++)
{
dp[j]=dp[j]+dp[j-w[i]];
}
}
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",dp[n]);
}
return ;
}
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2934
这题就是换零钱的变形
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main()
{
int T,n,dp[];
int w[]= {,,,,,,,,,,,,,,,,,,,,};
memset(dp,,sizeof(dp));
dp[]=;
for(int i=; i<=; i++)
{
for(int j=w[i]; j<=; j++)
{
dp[j]=dp[j]+dp[j-w[i]];
}
}
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",dp[n]);
}
return ;
}