摘要: hdu2489求一个图中的一颗子树,使得Sum(edge weight)/Sum(point weight)最小~数据量很小,暴力枚举,只是要注意精度,否则WA~dfs暴力枚举C(M,N)种情况。枚举出这M个点之后,Sum(point weight)固定,进行prime或者Kruskal使Sum(edge weight)求最小。View Code 1 #include 2 #include 3 #include 4 const int N=20; 5 const int inf=10000000; 6 int w[N];//用于记录每个点的权值 7 int ans[N];//用于记录答... 阅读全文
posted @ 2013-01-22 02:12 _sunshine 阅读(974) 评论(0) 推荐(0) 编辑
摘要: 感觉题意很扭曲。。。 不是求最大生成树!给一个图,求pseudoforest伪森林,要求每个连通分量最多可以有一个环。求能构成的最大值。 错误写法,求出最大生成树+最大的边 正确写法:在求最大生成树的思路的基础上每次判断一下环的问题~6 70 1 90 2 61 2 83 4 54 5 53 5 42 4 1这组数据如果是错误的方法就是34,选择(0,1),(1,2),(0,2),(2,4),(3,4),(4,5)正确的方法答案是37,选择(0,1),(1,2),(0,2),(3,4),(3,5),(4,5)View Code 1 #include <stdio.h> 2 #inc 阅读全文
posted @ 2013-01-22 02:05 _sunshine 阅读(457) 评论(0) 推荐(0) 编辑