QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 128 MB Points totaux : 10

#10383. 燃料 [B]

Statistiques

在过去的美好时光里,Byteland 的所有 $n$ 个城镇都由密集的双向道路网络连接。Byteland 的国王决定减少道路数量,并向他的首席计算机科学家寻求建议。现在,这一决定导致 Byteland 只剩下 $n-1$ 条双向道路连接着各个城镇,使得任意两个城镇之间恰好有一条路径。所有道路的长度都相同。

Byteasar 拥有一辆汽车,其油箱的燃料恰好足够行驶 $m$ 条道路。他决定组织一次旅行,以最大化访问城镇的数量。他可以从 Byteland 的任何一个城镇出发,旅行也可以在任何地方结束——不一定非要回到出发的城镇。在最大化访问城镇数量的过程中,Byteasar 允许在同一条道路上多次行驶,方向可以相同,也可以相反。你的任务是帮助 Byteasar 找出在加满一次油的情况下,最多可以访问多少个城镇。

输入格式

输入的第一行包含两个整数 $n$ 和 $m$ ($2 \le n \le 500\,000$, $1 \le m \le 200\,000\,000$),其中 $n$ 是 Byteland 的城镇数量(每个城镇的编号唯一,从 $\{1, \ldots, n \}$ 中选取),$m$ 是加满一次油可以行驶的道路数量。

接下来的 $n-1$ 行描述了 Byteland 的道路网络。每行包含两个整数 $a$ 和 $b$ ($1 \le a, b \le n$),表示城镇 $a$ 和 $b$ 之间有一条双向道路。

输出格式

输出一行,包含一个整数,表示在加满一次油的情况下,最多可以访问的城镇数量。

样例

输入 1

7 6
1 2
2 3
2 5
5 6
5 7
4 5

输出 1

5

说明 1

Byteasar 最多可以访问 5 个不同的城镇。对于此样例输入,有多种不同的路线可以访问 5 个城镇,包括 4 → 5 → 7 → 5 → 6 → 5 → 2 和 3 → 2 → 1 → 2 → 5 → 6 → 5。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.