51nod 1101 换零钱

完全背包

#include <iostream>

using namespace std;


//dp[i][j]
const int MAXN=1e5+5;
int a[]={1,2,5,10,20,50,100,200,500,1000,2000,5000,10000};
const int MOD=1e9+7;
int dp[MAXN];


int main()
{
    int n;
    cin>>n;
    dp[0]=1;
    for(int i=0;i<13;i++)
    {
        for(int j=a[i];j<=n;j++)
        {
            dp[j]=(dp[j]+dp[j-a[i]])%MOD;
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

相关文章:

  • 2021-12-27
  • 2021-05-17
  • 2021-12-27
  • 2021-12-02
  • 2021-06-03
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-22
  • 2022-01-18
  • 2022-03-04
  • 2021-08-27
  • 2022-01-26
相关资源
相似解决方案