QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 512 MB Points totaux : 100

#13103. Grundy

Statistiques

Grundy 值或 Sprague-Grundy 值是组合博弈分析中的有力工具。在本题中,你需要求出 Wythoff's Nim 的 Sprague-Grundy 值。

考虑一个无限大的第一象限棋盘,其格子由非负整数对索引。一个国际象棋皇后位于点 $(x, y)$,它可以移动到任何坐标为 $(x', y')$ 的格子,只要满足 $x = x'$ 或 $y = y'$ 或 $x - y = x' - y'$,且满足 $x' \le x$ 且 $y' \le y$。

格子 $(x, y)$ 的 Grundy 值定义为递归地等于不能从 $(x, y)$ 一步到达的格子的 Grundy 值集合中的最小非负整数 $g$。上表展示了坐标最大为 9 的格子的 Grundy 值。

给定 $g$ 和 $k$。考虑所有 Grundy 值为 $g$ 的格子。将它们按字典序排序:首先按 $x$ 坐标排序,然后按 $y$ 坐标排序。你需要找到其中第 $k$ 个格子。

输入格式

输入包含多个测试用例。每个测试用例占一行,包含两个整数 $g$ 和 $k$ ($0 \le g \le 10, 1 \le k \le 500\,000$)。最多有 1000 个测试用例。最后一个测试用例后跟一行包含两个零的行,该行无需处理。

输出格式

对于每个测试用例,输出两个整数:$x$ 和 $y$ —— 即 Grundy 值为 $g$ 的第 $k$ 个字典序格子的坐标。

样例

输入 1

0 1
0 2
0 3
0 4
1 1
1 4
2 1
2 4
0 0

输出 1

0 0
1 2
2 1
3 5
0 1
3 6
0 2
3 4

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.