Universal Cup Judging System

Universal Cup

Time Limit: 3 s Memory Limit: 512 MB Total points: 100
Statistics

The Doubling Game 更像是一个谜题而非游戏。游戏棋盘由 $n$ 个编号为 $1$ 到 $n$ 的区域组成。这些区域通过 $n-1$ 条线段连接,使得从任意一个区域出发,仅通过连接的线段即可到达其他任何区域。换句话说,游戏棋盘构成了一棵树。初始时,树的每个顶点恰好包含一个筹码。

唯一可用的移动方式是:选择两个由线段连接且包含相同(正整数)数量筹码的区域,并将其中一个区域的所有筹码转移到另一个区域。

你的任务是计算在经过任意(可能为空)次移动序列后,棋盘可能出现的不同筹码排列方案数。当且仅当存在至少一个区域在两种排列中包含的筹码数量不同时,这两种排列被视为不同。由于方案数可能非常大,你只需输出其对 $10^9 + 7$ 取模后的余数。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 3 \cdot 10^5$),表示棋盘上的区域数量。

接下来的 $n-1$ 行,每行包含两个整数 $a_i$ 和 $b_i$ ($1 \le a_i, b_i \le n; a_i \neq b_i$),表示区域 $a_i$ 和 $b_i$ 由一条线段连接。

输出格式

输出一行,包含一个整数,表示可能的筹码排列方案数对 $10^9 + 7$ 取模后的余数。

样例

样例输入 1

5
1 2
1 3
1 4
4 5

样例输出 1

21

说明

样例测试中的游戏棋盘(连同顶点编号)如下所示:

一些可能的筹码排列示例:

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.