QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100

#11227. 半回文

统计

一群历史学家潜入科尔乌斯遗迹(Ruins of Corvus),发现了一些神秘的二进制字符串。经过努力研究,他们发现这些字符串都是“半回文串”(Hemi Palindrome)。如果一个二进制字符串在忽略奇数位或偶数位(从 1 开始计数)上的数字后,剩下的部分正读和反读相同,则称其为半回文串。例如,“101111”是半回文串,因为其奇数位上的数字构成的序列为“111”。“11001”和“10100”也都是半回文串,而“101001”和“11000”则不是。

熊猫先生非常喜欢半回文串,他想知道长度为 $N$ 的第 $K$ 小的半回文串(按字典序排列)。

输入格式

输入的第一行包含测试用例的数量 $T$。接下来的 $T$ 行,每行包含两个整数 $N$ 和 $K$。

输出格式

对于每个测试用例,输出一行 “Case #x: y”,其中 $x$ 是测试用例编号(从 1 开始),$y$ 是按二进制格式输出的半回文串。如果长度为 $N$ 的半回文串少于 $K$ 个,则 $y$ 为 “NOT FOUND!”。

数据范围

  • $1 \le T \le 100$
  • $1 \le N \le 10^5$
  • $1 \le K \le 10^{18}$

样例

样例输入 1

4
2 1
3 3
3 5
3 100

样例输出 1

Case #1: 00
Case #2: 010
Case #3: 100
Case #4: NOT FOUND!

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.