摘要: 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <cstring> 5 6 #define MAX 1001 7 using namespace std; 8 9 struct cloth{10 int xi,yi,ci;11 };12 int dp[MAX][MAX]={0};13 14 int main(){15 int T;16 cin >> T;17 while(T--){18 int N,X,Y;19 cin >.. 阅读全文
posted @ 2013-04-09 23:18 OpenSoucre 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 此题一定要注意输入是 n || m 不是 n&&m, 就因为这个WA了几次此题是01背包的增加型,不要完全套01背包,由于是概率所以要考虑乘法,题目要求的是至少被录取,根据概率论,求其反面简单 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <cstdio> 5 #include <cstring> 6 7 using namespace std; 8 9 int main(){10 int n,m;11 while 阅读全文
posted @ 2013-04-09 21:43 OpenSoucre 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 像下面代码直接利用二进制求解多重背包会超时 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <vector> 5 #include <algorithm> 6 7 using namespace std; 8 9 int main(){10 int n,m;11 while(cin>>n>>m && n && m){12 vector<int> A(n),C(n);13 阅读全文
posted @ 2013-04-09 17:34 OpenSoucre 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 多维费用背包 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 5 using namespace std; 6 7 struct good { 8 int a,b,val; 9 };10 11 int main(){12 int n,v1,v2,k;13 while(cin >> n>>v1>>v2>>k){14 vector<good> commodity(n);15 for(int i = 0; i < 阅读全文
posted @ 2013-04-09 15:39 OpenSoucre 阅读(231) 评论(0) 推荐(0) 编辑