题目http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=615

分析:计算背包方案数目
#include<cstdio>
#include<cstring>

using namespace std;

int a[5]={1,5,10,25,50},dp[7500];
int amount;

int main()
{
  while (scanf("%d",&amount)!=EOF)
  {
    memset(dp,0,sizeof(dp));
    dp[0]=1;

    for(int i=0;i<5;i++)
      for(int j=a[i];j<=amount;j++)
        dp[j]=dp[j]+dp[j-a[i]];

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

  return 0;
}
 





相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2021-09-26
  • 2021-08-01
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
相关资源
相似解决方案