上一页 1 ··· 55 56 57 58 59 60 61 62 63 ··· 182 下一页
摘要: 最小生成树,我是用邻接表+map存储姓名做的,点开1000就够了。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <map>using namespace std;#define inf 0x3f3f3f3f#define maxn 1005#define maxl 25struct Edge{ int v, next; double w;}edge[maxn * maxn];int vis[maxn] 阅读全文
posted @ 2012-07-04 18:45 undefined2024 阅读(183) 评论(0) 推荐(0)
摘要: 状态压缩dp,数据弱,本程序时间效率O(12 * (2^24))View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 13#define mod 100000000int row, column;int filter[maxn];int f[maxn][1 << maxn];void input(){ scanf("%d%d", &r 阅读全文
posted @ 2012-07-04 16:01 undefined2024 阅读(524) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 1005int n, t;int f[maxn];bool vis[maxn];int num;void input(){ scanf("%d%d", &n, &t); for (int i = 0; i < n; i++) scanf("%d", &a 阅读全文
posted @ 2012-07-04 15:09 undefined2024 阅读(256) 评论(0) 推荐(0)
摘要: 01背包View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 105#define maxm 15#define maxl 50#define maxt maxn * 1000struct Cloth{ int t, c;}cloth[maxn];int m, n;char color[maxm][maxl];bool f 阅读全文
posted @ 2012-07-04 14:28 undefined2024 阅读(326) 评论(0) 推荐(0)
摘要: 题意:给定一些奶牛,每个牛有s和f两个属性值,有正有负,要求选出一些牛,使得这些牛的两种属性的和的加和最大,且这些牛的两种属性分别求加和不能为负。分析:dp,开始想到dp[i][s][f],表示前i头牛能否实现属性和分别为s,f。空间和时间都不允许,要将f从状态中拿出來,让f的属性和作为所求的值。即变为d[i][s]=f的形式。表示用前i头牛构成s属性和为s的情况下f属性和最大为多少。状态转移从两种情况来,即用或者不用当前的牛。dp[i][j] = max(dp[i - 1][j - s[i]] + f[i], dp[i - 1][j])。在实际操作的时候可以将第一维去掉,进行空间上的优化。但 阅读全文
posted @ 2012-07-04 13:45 undefined2024 阅读(1949) 评论(0) 推荐(2)
上一页 1 ··· 55 56 57 58 59 60 61 62 63 ··· 182 下一页