51nod oj 1101 换零钱【完全背包】
2016-08-13 10:45
169 查看
传送门:1101
硬币无限多---完全背包
代码:
#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
);
return 0;
}
硬币无限多---完全背包
代码:
#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
);
return 0;
}
相关文章推荐
- 【51Nod】1101 - 换零钱(完全背包)
- 51nod 1101 换零钱 完全背包的变型 动态规划
- 51nod 1101 换零钱 完全背包计数
- 51nod 1101 换零钱 (完全背包)
- 51nod 1101 换零钱 完全背包
- 51nod 1101 换零钱 (0-1背包,DP)
- 51Nod-1101 换零钱【0/1背包+DP】
- 完全背包模板 51Nod 1101
- 51nod 1101换零钱(背包)
- 小P的故事——神奇的换零钱(完全背包)
- zzulioj 1782: 和尚特烦恼8——找零钱 (完全背包)
- 寒假训练--01背包完全背包--小P的故事——神奇的换零钱
- 51nod 1101 完全背包
- POJ1276 找零钱(多重背包 或 二进制拆分 或 递归)
- HDU 1114 Piggy-Bank (完全背包)
- HDU 5534 Partial Tree (变形完全背包 好题)
- HDU-1114 Piggy-Bank 完全背包的灵活运用
- HDU 1114 Piggy-Bank (完全背包)
- NYOJ - 完全背包(经典dp)
- zoj3623-完全背包(向前插入)