51nod1101换零钱

51nod1101换零钱
就是一个完全背包问题。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
long long dp[100100],mod,ans;
int main()
{
    int shu[14]={0,1,2,5,10,20,50,100,200,500,1000,2000,5000,10000};
    int n;
    scanf("%d",&n);
    mod=1000000007;
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<=13;i++)
        for(int j=shu[i];j<=n;j++)
        dp[j]=(dp[j]+dp[j-shu[i]])%mod;
    printf("%d\n",dp[n]);
    return 0;
}

发布了29 篇原创文章 · 获赞 3 · 访问量 3205

猜你喜欢

转载自blog.csdn.net/qq_38436175/article/details/75569031
今日推荐