QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100

#6641. 异或骰子

الإحصائيات

给定两个整数 $n$ 和 $d$。

请找出 $n$ 个骰子,每个骰子的六个面上标有不超过 $10^6$ 的非负整数,使得:

  • 对于每个骰子,其六个面上的数字各不相同;
  • 掷出所有骰子后,这 $n$ 个骰子朝上的数字的按位异或和(bitwise XOR)始终能被 $d$ 整除。

在给定的约束条件下,可以证明这样的骰子总是存在的。

输入格式

输入仅一行,包含两个整数 $n$ 和 $d$ ($1 \le n \le 100; 2 \le d \le 60$),分别表示骰子的数量以及异或和需要被整除的数。

输出格式

输出 $n$ 行,第 $i$ 行包含六个不超过 $10^6$ 的互不相同的非负整数,表示第 $i$ 个骰子的六个面。

如果存在多种可能的答案,输出其中任意一种即可。

样例

输入 1

3 2

输出 1

1 3 5 7 9 11
3 5 7 9 11 2023
0 2 4 6 100000 10

说明

这里有三个骰子:

  • 骰子 1 的面为 $[1, 3, 5, 7, 9, 11]$。
  • 骰子 2 的面为 $[3, 5, 7, 9, 11, 2023]$。
  • 骰子 3 的面为 $[0, 2, 4, 6, 100000, 10]$。

假设我们掷出了这些骰子,结果分别为 $7, 3, 2$。那么它们的按位异或和为 $7 \oplus 3 \oplus 2 = 6$,这确实是 $2$ 的倍数。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#135EditorialOpen题解jiangly2025-12-12 23:29:32View

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.