HDUOJ 2069 COINchange(母函数用的二维费用背包)

it2024-10-31  9

#include<iostream>#include<cstdio>#include<cmath>#include<vector>#include<cstdlib>using namespace std;

int main(){ int dp[260][105]; int a[5]={50,25,10,5,1}; int n; memset(dp,0,sizeof(dp)); for (int i = 0; i < 100; i++) {  dp[0][i]=1; } for (int i = 0; i < 5; i++) {  for (int j = a[i]; j <= 250; j++)  {   for (int k = 1; k <= 100; k++)   {    if (dp[j-a[i]][k-1])    {     dp[j][k]+=dp[j-a[i]][k-1];    }   }  } } while(scanf("%d",&n)!=EOF) {  if(n==0)  {   printf("1\n");   continue;  }  printf("%d\n",dp[n][100]); }// system("pause"); return 0;}

转载于:https://www.cnblogs.com/Skyxj/p/3179478.html

最新回复(0)