上一页 1 ··· 178 179 180 181 182
摘要: 网络流的最小割问题,看到分配成两部分的题,就要想到网络流最小割,割值是一部分指向另一部分的边的初始容量的总和,不加上另一部分指向本部分的边的容量。而对于最小割来说,最大流流量就是最小割的容量。而划分方法,就是将最大流后残余网络中s可以走到的点划为s集合,其余点划为t集合,注意,不是可以走到t的点,因为有可能有一条线上的多条边都流满的情况,这种情况下有些点就无法走到t,而且s也走不到它。 阅读全文
posted @ 2011-02-01 12:49 金海峰 阅读(1514) 评论(0) 推荐(0) 编辑
摘要: 字符串处理简单题,注意reverse()的使用,这个函数要包含"algorithm" 阅读全文
posted @ 2011-02-01 12:46 金海峰 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 题意:给定三个矩阵a,b,c,问a×b是否等于c?分析:只需要设置一个列向量x,求a*(b*x),求c*x,看是否相等即可。当然这不能保证正确,x是生成的随机向量,多次生成多次测试即可使错误概率大大减小。#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <ctime>#include <algorithm>using namespace std;const int maxn = 510;long lon 阅读全文
posted @ 2011-02-01 12:45 金海峰 阅读(705) 评论(0) 推荐(0) 编辑
摘要: 树状数组题意:给定一棵树,某些节点上有苹果,多次询问各子树上的节点数,并且在询问的中途随时可能新增和删除苹果。分析:dfs遍历树的同时,对每个点标注时间,每个点有一个开始时间和一个结束时间,把这两个时间当做下标,该点的苹果个数(1或0)填入数组的两个对应位。子树中结点的时间段一定是根节点时间段的子段,所以求子树苹果数,只需求数组某区间的和即可。用树状数组比较快。#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>using namespace std;#d 阅读全文
posted @ 2011-02-01 12:44 金海峰 阅读(2457) 评论(0) 推荐(0) 编辑
摘要: 水题,求平均数#include <stdio.h>int main(){ //freopen("D:\\t.txt", "r", stdin); int n; while (scanf("%d", &n) != EOF && n != 0) { int i; int xmin, xmax, sum; scanf("%d", &xmin); xmax = xmin; sum = xmin; for (i = 1; i < n; i++) { int a; scanf( 阅读全文
posted @ 2011-02-01 12:38 金海峰 阅读(264) 评论(0) 推荐(0) 编辑
上一页 1 ··· 178 179 180 181 182