QOJ.ac

QOJ

Time Limit: 1.5 s Memory Limit: 64 MB Total points: 100 Hackable ✓

#10836. 平衡树

Statistics

如果一棵二叉树 $T$ 为空,或者同时满足以下三个条件,则称其为超平衡(super balanced)二叉树:

  1. $T$ 的左子树是超平衡的。
  2. $T$ 的右子树是超平衡的。
  3. $T$ 的左子树节点数与右子树节点数之差不超过 1。

请计算由 $n$ 个节点组成的超平衡二叉树的数量。由于答案可能非常大,请输出答案对 $2^{64}$ 取模的结果。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 10^6$),表示测试用例的数量。 每个测试用例包含一个整数 $n$ ($0 \le n < 2^{64}$),表示树中的节点数。

输出格式

对于每个测试用例,输出一行,包含一个整数,表示由 $n$ 个节点组成的超平衡二叉树的数量。

样例

样例输入 1

2
2
3

样例输出 1

2
1

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.