POJ The Fewest Coins
来源:互联网 发布:疯狂追星 知乎 编辑:程序博客网 时间:2024/04/30 20:30
转载请注明出处__谢谢! http://blog.csdn.net/huiyuan_ai?viewmode=contents by---huiyuan_ai第一次写这个东东,不好的地方还请提出,另求认识大神(ˇ^ˇ),目前只会水题- -#~~~!
题目链接:http://poj.org/problem?id=3260
这个题目,TLE的做法- -#~~~!完全背包+多重背包
#include <stdio.h>#define inf 1000000000int c[150],w[150];int min(int a,int b){return a<b?a:b;}int dp[11015];void zero(int x,int y){for(int j=10000;j>=x;j--)dp[j]=min(dp[j],dp[j-x]+y);}int main(){int i,j,n,s,k;while(~scanf("%d%d",&n,&s)){for(i=0;i<=10000;i++)dp[i]=inf;dp[0]=0;for(i=1;i<=n;i++)scanf("%d",&w[i]);for(i=1;i<=n;i++)scanf("%d",&c[i]);for(i=1;i<=n;i++)for(j=0;j<=c[i];j++)zero(w[i],1);for(i=1;i<=n;i++)for(j=10000-w[i];j>=0;j--)dp[j]=dp[j]<dp[j+w[i]]+1?dp[j]:dp[j+w[i]]+1;printf("%d\n",(dp[s]!=inf)?dp[s]:-1);}}
- POJ The Fewest Coins
- The Fewest Coins POJ
- poj 3260 the fewest coins
- POJ-3260-The Fewest Coins
- POJ 3260 The Fewest Coins
- poj 3260 The Fewest Coins
- poj 3260 The Fewest Coins
- poj 3260 The Fewest Coins
- poj 3260 The Fewest Coins
- POJ 2082 The Fewest Coins
- POJ 3260The Fewest Coins (DP)
- poj 3260 The Fewest Coins(背包)
- POJ 3260 The Fewest Coins / 混合背包
- poj 3260 The Fewest Coins(背包)
- 【DP】 POJ 3260 The Fewest Coins 背包
- POJ - 3260 The Fewest Coins (完全背包)
- POJ 3260 The Fewest Coins 已翻译
- poj3260 The Fewest Coins
- 玩转Google开源C++单元测试框架Google Test系列(gtest)之二 - 断言
- jprofiler 7.X注册码
- Linux 内核配置机制(make menuconfig、Kconfig、makefile)讲解
- 变量~HLSL
- 玩转Google开源C++单元测试框架Google Test系列(gtest)之三 - 事件机制
- POJ The Fewest Coins
- 玩转Google开源C++单元测试框架Google Test系列(gtest)之四 - 参数化
- DELPHI高性能大容量SOCKET并发(九):稳定性问题解决
- Android 资源(resource)学习小结
- make menuconfig 执行流程分析
- 玩转Google开源C++单元测试框架Google Test系列(gtest)之五 - 死亡测试
- Linux source code Makefile分析
- DELPHI高性能大容量SOCKET并发(十):IOCP完成端口性能优化
- 如何带领好团队