HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化) 题意分析 先把每种硬币按照二进制拆分好,然后做01背包即可.需要注意的是本题只需要求解可以凑出几种金钱的价格,而不需要输出种数.因此用0表示不可以,1表示可以.最后对dp数组扫描一遍即可. 代码总览 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define nmax 100…
HDOJ(HDU).1059 Dividing(DP 多重背包+二进制优化) 题意分析 给出一系列的石头的数量,然后问石头能否被平分成为价值相等的2份.首先可以确定的是如果石头的价值总和为奇数的话,那么肯定不能被平分.若为偶数,则对valuesum/2为背包容量,全体石头为商品做完全背包.把完全背包进行二进制优化后,转为01背包即可. 代码总览 #include <iostream> #include <cstdio> #include <cstring> #inclu…
Dividing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23277    Accepted Submission(s): 6616 Problem Description Marsha and Bill own a collection of marbles. They want to split the collection…
题意是给你几个数,再给你这几个数的可以用的个数,然后随机找几个数来累加, 让我算可以累加得到的数的种数! 解题思路:先将背包初始化为-1,再用多重背包计算,最后检索,若bb[i]==i,则说明i这个数是可以得到的!一个循环计算可以达到的数的个数,最后输出就好了! #include<stdio.h> #define max(a,b) a>b?a:b int bb[500000]; int vv; void shun(int cost,int weight) { int i; for(i=c…
bitset做法 #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vector<int…
点我看题目 题意 :Whuacmers有n种硬币,分别是面值为A1,A2,.....,An,每一种面值的硬币的数量分别是C1,C2,......,Cn,Whuacmers想买钱包,但是想给人家刚好的钱,不喜欢再找钱那么麻烦,但是他不知道钱包的具体钱数,只知道不会超过m,所以问你手里的钱能表示多少个不超过m的钱数. 思路 :多重背包.不知道的去搜背包九讲,几乎都一样. 我想说这个小哥儿真逗 #include <stdio.h> #include <string.h> #include…
<题目连接> 题目大意: 一位同学想要买手表,他有n种硬币,每种硬币已知有num[i]个.已知手表的价钱最多m元,问她用这些钱能够凑出多少种价格来买手表. 解题分析: 很明显,这是一道多重背包的问题,下面是用二进制拆分的多重背包的万能模板. #include <bits/stdc++.h> using namespace std; const int INF = 1e9; ],cnt[],dp[)]; void OneZeroPack(int m,int v,int value){…
Problem Description Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same value, because then they could…
hdu(1171) Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19752    Accepted Submission(s): 6900 Problem Description Nowadays, we all know that Computer College is the biggest…
Food Problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5445 Description Few days before a game of orienteering, Bell came to a mathematician to solve a big problem. Bell is preparing the dessert for the gam…