QOJ.ac

QOJ

时间限制: 3 s 内存限制: 256 MB 总分: 100

#10940. 去吧,去恢复!

统计

Teacher Mai 有一张 $p$ 进制的乘法表。 例如,以下是 $4$ 进制的乘法表:

* 0 1 2 3
0 00 00 00 00
1 00 01 02 03
2 00 02 10 12
3 00 03 12 21

但是一个淘气的孩子将 $0 \dots p-1$ 这些数字映射到了另一个排列,并打乱了乘法表。 例如,Teacher Mai 只能看到:

$1*1=11 \quad 1*3=11 \quad 1*2=11 \quad 1*0=11$ $3*1=11 \quad 3*3=13 \quad 3*2=12 \quad 3*0=10$ $2*1=11 \quad 2*3=12 \quad 2*2=31 \quad 2*0=32$ $0*1=11 \quad 0*3=10 \quad 0*2=32 \quad 0*0=23$

Teacher Mai 希望你恢复这张乘法表。请输出 $0 \dots p-1$ 被映射成的排列。 保证解是唯一的。

输入格式

输入包含不超过 $150$ 组测试数据,以一行 “0” 结束。 对于每组测试数据,第一行包含一个整数 $p$ ($2 \le p \le 500$)。 接下来的 $p$ 行中,每行包含 $2p$ 个整数。第 $i$ 行的第 $(2j+1)$ 个数 $x$ 和第 $(2j+2)$ 个数 $y$ 表示在打乱后的乘法表中方程 $i \cdot j = xy$。输入文件大小不超过 $47$ MB。

输出格式

对于每组数据,输出一行,包含 $p$ 个整数,表示 $0 \dots p-1$ 被映射成的排列。

样例

样例输入 1

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

样例输出 1

1 3 2 0

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.