上一页 1 2 3 4 5 6 ··· 10 下一页
摘要: 弱菜的做法,生成所有子集,然后从集合元素个数少的开始判断。有一个大坑是,所有的格子都是空地,这种情况下不用放,输出0。 1 #include <algorithm> 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 using namespace std; 6 struct sub{ 7 int u; 8 int v; 9 int w; 10 }q[2001]; 11 12 struct node{ 13 int b[2001]; 14 int num; ... 阅读全文
posted @ 2012-11-08 22:10 pony1993 阅读(410) 评论(0) 推荐(0) 编辑
摘要: 对于两组数据 x1 y1和x2 y2根据题目可以得出如果第一组数据排在第二组数据前面,那么x1*y2<x2*y1。所以只要排下序就可以了。代码: 1 #include <algorithm> 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #define LL long long 6 using namespace std; 7 struct node 8 { 9 LL x;10 LL y;11 }p[100010];12 const LL mod=365*2 阅读全文
posted @ 2012-10-29 22:04 pony1993 阅读(482) 评论(0) 推荐(0) 编辑
摘要: 转自:http://blog.renren.com/blog/315991004/876120504以下语言环境为g++猜猜看这些代码的输出结果?printf("%0.1lf\n", 0.05);printf("%0.1lf\n", 0.25);printf("%0.1lf\n", 0.75);printf("%0.2lf\n", 0.025);printf("%0.2lf\n", 0.015);printf("%0.2lf\n", 0.125);有人可能会说了这不是很简单的 阅读全文
posted @ 2012-10-19 18:05 pony1993 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3469sollution:把两个CPU视为源点和汇点、模块视为顶点。源点到第i个模块连容量为Ai的边,第i个模块到汇点连容量为Bi的边,然后两个特殊模块连双向边。根据最大流最小割定理,求最大流。代码: 1 #include <algorithm> 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #include <queue> 6 using namespace std; 7 const i 阅读全文
posted @ 2012-10-10 17:31 pony1993 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 转自mjmjmtl大牛:一、基本问题:1.到底什么是割:原始点集为V,选出一些点集S使得s∈S,T=V-S,t∈T,则S到T的边为S到T割,记做[S,T]。2.什么是最小割:图中所有的割中,边权值和最小的割为最小割!3.割得容量容量和流量计算的区别:割[S,T]的容量为∑(边(u,v)的容量和),其中u∈S,∈T。也就是说割的容量不计算反向的边!!而流量为正向的和反向的代数和。4.最大流-最小割定理:最大流的值为最小割的容量!5.怎样求割:求完最大流后,在残留网络中从source开始dfs,被染色的为S,未被染色的为T,则边集[S,T]为割。(或者从sink反向dfs,被染色的为T,未被染色的 阅读全文
posted @ 2012-10-10 16:38 pony1993 阅读(444) 评论(1) 推荐(0) 编辑
摘要: unsigned int 0~4294967295int 2147483648~2147483647unsigned long 0~4294967295long 2147483648~2147483647long long-9223372036854775808~9223372036854775807unsigned long long的最大值:1844674407370955161 阅读全文
posted @ 2012-10-06 10:07 pony1993 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 思路:(1)对图中每条边,扫描其他边,如果存在相同权值的边,则对该边做标记。(2)然后用Kruskal求MST。(3)求得MST后,如果该MST中未包含做了标记的边,即可判定MST唯一,如果包含了做了标记的边,则依次去掉这些再求MST,如果求的MST权值和原MST权值相同,即可判定MST不唯一。代码: 1 #include <algorithm> 2 #include <iostream> 3 #include <cstring> 4 #include <cstdlib> 5 #include <cstdio> 6 #include 阅读全文
posted @ 2012-10-04 11:13 pony1993 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 给你n张卡片,分给k个人,从1-n轮流分。然后,重新把卡片放在一起。第1个人的放在最上边,后面的依次放下面。 再重新分,再放,问多少次后会恢复原样。10 3第一次10 7 4 1 8 5 2 9 6 3第二次3 2 1 10 9 8 7 6 5 4第三次4 7 10 3 6 9 2 5 8 1第四次1 2 3 4 5 6 7 8 9 10 1 #include <algorithm> 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #define LL long l 阅读全文
posted @ 2012-10-03 15:30 pony1993 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 求解最大流一般采用两种思路,一种是预流,另一各是增广路。增广路这种思想是基于以下定理:定理一:设网络 G 的源为 S, 汇和 T,F和 C 分别为 G 的流和容量,则 F 是最大流当且仅当 G 中不存在可增广路。由此定理可以设计很多算法来计算最大流,Dinic 算法是其中一种比较高效的方法,其复杂度为 O(n2*m)Dinic 算法的基本步骤为:1) 计算残余网络的层次图。我们定义 h[i] 为顶点 i 距离源 S 所经过到最小边数,求出所有顶点的 h 值,h[] 值相同的顶点属于同一层,这就是网络的层次图。2) 在层次图上进行 BFS 增广,直到不存在增广路径。这时求得的增广路径上顶点是分层 阅读全文
posted @ 2012-10-01 17:12 pony1993 阅读(621) 评论(1) 推荐(0) 编辑
摘要: 有N个岛屿 M条无向路 每个路有一最大允许的客流量,求从最西的那个岛屿最多能运用多少乘客到最东的那个岛屿。 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <queue> 5 #define M 410000//边 6 #define N 110000//点 7 using namespace std; 8 #define INF 0x3f3f3f3f 9 struct edge 10 { 11 int from; 12 int to; 13 in 阅读全文
posted @ 2012-09-30 16:22 pony1993 阅读(159) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 10 下一页

View My Stats