QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 32 MB Puntuación total: 140

#16641. DLAKAVAC

Estadísticas

在遥远的世外桃源 Xanadu,爆发了一场由被称为“多毛流感”(hairy flu)的病毒引起的流感疫情。

城市里居住着 $M$ 个人,每个居民都有一个唯一的个人身份证号(ID),范围在 $0$ 到 $M - 1$ 之间(含两端)。感染该病毒的症状恰好持续一天,且一个人在一个流行季内可以多次感染(因为病毒变异极快,无法产生持久免疫力)。

在疫情爆发的第一天,流感由一群被称为“初始患者”(init-patients)的居民从另一个遥远的国家传入,他们的 ID 是已知的。流感的传播正是基于他们。

在接下来的每一天中,ID 为 $p$ 的居民会被感染,当且仅当存在一个在前一天被感染的 ID 为 $a$ 的居民,以及一个 ID 为 $b$ 的初始患者,满足: $$(a \times b) \bmod M = p$$

数字 $a$ 和 $b$ 不需要是不同的。例如,假设镇上有 $101$ 个人,初始患者为 $5$ 和 $50$。根据定义,第一天被感染的是初始患者。第二天,被感染的居民为 $25$、$48$(即 $250 \bmod 101$)和 $76$(即 $2500 \bmod 101$)。第三天,其中一个被感染的患者是 $77$,因为 $(48 \times 50) \bmod 101 = 77$。

请问在第 $K$ 天谁会感染流感?

输入格式

输入的第一行包含三个正整数 $K$,$M$ 和 $N$($1 \le K \le 10^{18}$,$3 \le M \le 1500$,$N < M$)。

输入的第二行包含 $N$ 个空格分隔的非负整数,表示在第一天被感染的居民(初始患者)的个人 ID。这些数字是唯一的、递增的,且不超过 $M - 1$。

输出格式

输出的第一行也是唯一的一行,应包含在第 $K$ 天感染流感的居民的个人 ID,按升序排列,并用空格分隔。

样例

输入样例 1

1 100 3
1 2 3

输出样例 1

1 2 3

输入样例 2

2 100 3
1 2 3

输出样例 2

1 2 3 4 6 9

输入样例 3

10 101 2
5 50

输出样例 3

36 44 57 65

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.