Justified Jungle
题目链接:Justified Jungle
那么割 x 条边,剩下 (x+1) 个连通块,且大小为 n/(x+1) ,所以我们树的子树size为 n/(x+1) 的个数一定要有x+1个。
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=1e6+10;
int n,sz[N],cnt[N];
vector<int> g[N];
inline void add(int a,int b){g[a].push_back(b),g[b].push_back(a);}
void dfs(int x,int fa) {sz[x]=1;for(auto to:g[x]) if(to!=fa) dfs(to,x),sz[x]+=sz[to];cnt[sz[x]]++;
}
inline int check(int x) {if(n%x) return 0;int tmp=0,w=n/x;for(int i=w; i<=n; i+=w) tmp+=cnt[i];return tmp>=x;
}
signed main() {cin>>n;for(int i=1,a,b; i<n; i++) scanf("%d %d",&a,&b),add(a,b);dfs(1,1);for(int i=1; i<n; i++) if(check(i+1)) printf("%d ",i);return 0;
}
Justified Jungle相关推荐
- 题目1154:Jungle Roads
题目描述: The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money ...
- HDU 1301 Jungle Roads(裸最小生成树)
题目链接 今天做了好几个模版最小生成树...贴一个kurskral. 1 /* 2 HDU 1301 Jungle Roads 3 最小生成树Kurskal模版 4 */ 5 #include < ...
- hdu 1301 Jungle Roads 最小生成树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301 The Head Elder of the tropical island of Lagrish ...
- 【HDU - 1301】Jungle Roads(并查集+最小生成树)(内附最小生成树两种算法 克鲁斯特尔算法amp;amp;普里姆算法)
题干: Jungle Roads Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- (kruskal)Jungle Roads
题目 The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money wa ...
- 松下抛却Jungle掌机研发项目
网易科技讯 3月1日动静,据路透社报道,松下周二发挥分析,公司已抛却Jungle掌下游戏机的研发项目. 去年十月,关于松下宣布该研发项目的动静让业界颇为惊奇. 松下十多年前就曾经撤出游戏局限,很多分析 ...
- Jungle Roads//最小生成树kruskal
题目: Jungle Roads Time Limit: 2 Seconds Memory Limit: 65536 KB The Head Elder of the tropical is ...
- Jungle Scout中国市场首发亚马逊FBA卖家百万美金案例中文版详解
-Jungle Scout 开始为中国亚马逊卖家译制第四期百万美金案例 -百万美金案例分享完全免费,可以在Jungle Scout的官方微信公众号.微博以及QQ 群及时收到更新 深圳2018年10月9 ...
- 2020年AJ超级配乐库音频配乐资源2020.VOL-09更新100首Audio Jungle音乐素材包
2020年AJ超级配乐库音频配乐资源2020.VOL-09更新100首Audio Jungle音乐素材包 原文地址:https://www.aeziyuan.com/t-20607.html 了解或者 ...
最新文章
- 小米澄清传闻:不存在跨境转移利润及逃避缴纳税款行为
- 前缀和与差分的使用(新手快速入门)
- SpringMVC 中xml 配置多数据源
- 博客园Logo创意之我的朋友弄的
- Kubernetes里ingress配置的一些例子
- 使用libxml提示libxml/tree.h找不到的问题解决
- go mongodb排序查询_《MongoDB》day two
- DataTable,DataView和DataGrid中一些容易混淆的概念
- 数据结构上机实践第八周项目2- 建立链串的算法库
- 为原生对象添加方法的潜在危险
- android播放器demo,Android 简单的本地音乐播放器Demo
- jQuery版本的区别
- 使用Word(Office 365)版本中的简历助手
- Linux版本的SVN客户端,好的Linux(Ubuntu)SVN客户端
- 2020-10-27
- 你是否也陷入了《能力陷阱》?
- 什么是工业DTU?工业DTU特点及应用领域分析
- Debian7.5--双屏显示问题
- apache2 docker 无法访问_Docker 安装 Apache
- mysql和oracle复杂查询语句_oracle表复杂查询
热门文章
- 计算机视觉综述性论文Intelligent Visual Media Processing: When Graphics Meets Vision翻译
- 设计模式 | 建造者模式及典型应用
- No 和 Not 的区别
- 浅谈PCA到PCANet
- 文本域、标签、密码域、文本区、滚动窗格——文本输入
- 可汗学院”(Khan Academy)提出的考验智商的谜题
- 考夫曼自适应均线_采访:查理·考夫曼
- 【noHandlerFound(DispatcherServlet.java:1278)和No mapping for GET】SpringMVC 404和中文乱码问题和解决方案记录
- 【python+E-prime+fNIRS】探究认知资源在情绪与认知灵活性中是否存在中介效应课题
- 通俗讲解 依概率收敛,大数定理和中心极限定理