题意:树上每个节点上有若干苹果,边上带权,问你最小费用使得书上的苹果方差最小。思路:上下费用流问题,参考http://blog.csdn.net/qq564690377/article/details/8870587代码如下: 
1 /********************************....
                            
                            
                                分类:
其他好文   时间:
2014-05-16 21:50:35   
                                阅读次数:
491
                             
                    
                        
                            
                            
                                这题那时怎么想就是想不出来……而且今晚没有多大状态,自己都晕了……一题没做出来……
baoge解释好久才懂……唉……线段树,树状数组用得还是不够熟啊……
WA了二发,才知道二分错了,二分好久不用,老是出错了现在……
#include
#include
#include
#include
#define sca(a) scanf("%d",&a)
#define mem(a,b) memset...
                            
                            
                                分类:
其他好文   时间:
2014-05-15 03:30:49   
                                阅读次数:
223
                             
                    
                        
                            
                            
                                广度优先搜索(Breadth-First-Search)和深度优先搜索(Deep-First-Search)是搜索策略中最经常用到的两种方法,特别常用于图的搜索.其中有很多的算法都用到了这两种思想,比如:Dijkstra单源最短路径算法和Prim最小生成树算法都采用了和宽度优先搜索类似的思想。BFS...
                            
                            
                                分类:
其他好文   时间:
2014-05-14 12:29:53   
                                阅读次数:
544
                             
                    
                        
                            
                            
                                zoj 3673 1 /** 2 6700417 3 **/ 4 #include 5 
#include 6 #include 7 #include 8 #include 9 using namespace std;10 11 typedef 
unsigned long long LL;12 13 ...
                            
                            
                                分类:
其他好文   时间:
2014-05-13 18:07:32   
                                阅读次数:
234
                             
                    
                        
                            
                            
                                Robert is clipping his fingernails. But the nail clipper is old and the edge of the nail clipper is potholed.
The nail clipper's edge is N millimeters wide. And we use N characters('.' or '*') to rep...
                            
                            
                                分类:
其他好文   时间:
2014-05-13 15:05:54   
                                阅读次数:
264
                             
                    
                        
                            
                            
                                Mahjong is a game of skill, strategy and calculation and involves a certain degree of chance. In this problem, we concentrate on Japanese Mahjong, a variation of mahjong. For brief, all of the word ma...
                            
                            
                                分类:
其他好文   时间:
2014-05-13 14:59:51   
                                阅读次数:
356
                             
                    
                        
                            
                            
                                1729 is the natural number following 1728 and preceding 1730. It is also known as the Hardy-Ramanujan number after a famous anecdote of the British mathematician G. H. Hardy regarding
 a hospital vis...
                            
                            
                                分类:
其他好文   时间:
2014-05-13 14:52:34   
                                阅读次数:
314
                             
                    
                        
                            
                            
                                Mahjong is a game of skill, strategy and calculation and involves a certain degree of chance. In this problem, we concentrate on Japanese Mahjong, a variation of mahjong. For brief, all of the word ma...
                            
                            
                                分类:
其他好文   时间:
2014-05-13 13:54:14   
                                阅读次数:
463
                             
                    
                        
                            
                            
                                中心节点就是树的中心,2遍dfs求到树的直径,而中心一定在直径上,顺着直径找到中心就够了。
然后可以一遍树形DP找到最小值或者二分+判断是否访问到叶子节点。
#include 
#include
#include
#include
using namespace std;
struct node
{
    int next;
    int power;
    int length...
                            
                            
                                分类:
其他好文   时间:
2014-05-13 11:28:38   
                                阅读次数:
306
                             
                    
                        
                            
                            
                                思路:半夜了思路有点混乱wa了好几发。一开始坑定两个人距离为m才能获得最大的收益,所以我们就可以枚举单个端点,当距离达到m时在一同一个方向走这是我们只需要算一下剩下几秒,左右两边贪心去最大的即可。代码如下: 
1 /*******************************************...
                            
                            
                                分类:
其他好文   时间:
2014-05-13 09:58:02   
                                阅读次数:
268