摘要:
HDU 2660http://acm.hdu.edu.cn/showproblem.php?pid=2660題意就不說了,直接走代碼。View Code #include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>using namespace std;#define max(a, b) (a>b?a:b)int V[21], W[21], Ans, N, K, L, i;void DFS(int p, int vv,
閱讀全文
摘要:
先說一下多重背包問題。他是由完全背包而來的,但是不同的是,他的每件物品有一定的數量限量,而完全背包中每種物品可以有無限件。HDU 2660http://acm.hdu.edu.cn/showproblem.php?pid=2660題目大意:在N件物品中,最多可以選擇K,在選擇的K件物品中,總容量不能超過W.求選擇的最大價值。本題就是一個任意組合問題了,當然除了這種解法以外還有一種解法。那就是DFS了。View Code #include<iostream>#include<cstdio>#include<cstring>#include<string&
閱讀全文
摘要:
HDU 1016http://acm.hdu.edu.cn/showproblem.php?pid=1016題目大意:給定一個數N,從1到N的這些整數構成一個環,它的目的就是讓你找出第相鄰兩個數都是素數的環。而且是所有的環。View Code #include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>using namespace std;int N;bool vis[21];int pre[21];bool prime[
閱讀全文