hdu1055】的更多相关文章

Color a Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 828    Accepted Submission(s): 272 Problem DescriptionBob is very interested in the data structure of a tree. A tree is a directed gr…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1055 题意:给一棵树涂色,这棵树的每个节点都有自己的价值Ci,涂色的原则是只由这个节点的父节点涂色之后才能涂色(就是从根节点开始涂色). 每次涂色用时1s,每个节点的涂色花费是Ci*Fi(Fi是从最开始到涂色到这个节点所花的时间).对这棵树涂色的总涂色花费为sum, 求怎样涂色才能使sum最小. 思路: 结论:对于一个非根节点,它具有最大的权值,只有先访问完它的父节点再访问它才能使总花费最小. 1.…
#include<iostream> #include<iomanip> #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<cmath> #include<map> #include<stack> #include<set> #include<queue> #in…