内存限制:256 MB
时间限制:2 S
题面:Markdown
评测方式:文本比较
上传者:
提交:5
通过:3
Given a tree where all edge weights are $\textstyle 1$, define $\textstyle f(u)=\sum_v dis(u,v)$, where $\textstyle v$ represents all nodes in the tree, and $\textstyle dis(u,v)$ is the length of the simple path between node $\textstyle u$ and node $\textstyle v$.
A tree is called “good” if there exist two nodes $\textstyle u$ and $\textstyle v$ such that $\textstyle f(u)-f(v)=x$. Given integer $\textstyle x$, determine the minimum number of nodes required for the tree to be “good”.
For each test case, output a single integer, representing the minimum number of nodes required for the tree to be “good”.
It can be shown that the answer always exists.