题目大意:删去k条边,树变为相等个点的连通分量,求所有正整数k. 解题关键:树dp,不必求因子. #include<bits/stdc++.h> using namespace std; typedef long long ll; #define maxn 1000006 int head[maxn],cnt,siz[maxn],v[maxn],n; struct edge{ int to,nxt; }e[maxn<<]; void add_edge(int u,int v){ e…
题意: 给出一棵树,删掉其中一些边,要求生成的每个子树节点数一样.输出所有可以删掉的边数. 题解: 以节点1为根,预处理每个子树的大小.对于每个n的因数x,还需满足子树为他倍数的点够n/x个,那么删的边数就为n/x-1. #include <bits/stdc++.h> using namespace std; ; int n; int u, v; int sz[N], vis[N]; int tot; ], nxt[N<<]; vector<int> ans; voi…
poj 1251 Jungle Roads (最小生成树) Link: http://poj.org/problem?id=1251 Jungle Roads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 23507 Accepted: 11012 Description The Head Elder of the tropical island of Lagrishan has a problem. A b…
Jungle Roads Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7096 Accepted Submission(s): 5185 Problem Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of…
Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expensi…
D - Jungle Roads Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1251 Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extr…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301 The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly,…