题意:给出n种面值的硬币, 和这些硬币每一种的数量, 要求求出能组成的钱数(小于等于m) 思路:一开始直接用多重背包套上去超时了,然后就没辙了,然后参考网上的,说只需要判断是否能取到就行了,并不需要记录其价格,直接用bool判断是否能取到.就不会TLE了. 代码: #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,m; int v,sum; int a[200…
题意:多重背包模型 n种物品 每个m个 问背包容量下最多拿多少 这里要用二进制优化不然会超时 #include<iostream> #include<cstdio> #include<cstring> using namespace std; +; int dp[maxn]; ],c[]; int main(){ int n,m,maxnum; while(cin>>maxnum>>n){ int a,b; ; ;i<=n;i++){…
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35387 Accepted: 12816 Description A Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropriate @ bills for a requested cash amount. The machine uses e…
http://poj.org/problem? id=1742 Description People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony opened his money-box and found there were some coins.He decided to buy a very nice watch in a nearby shop…