CF1190F.Tokitsukaze and Powers

NOI/NOI+/CTSC

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Tokitsukaze is playing a room escape game designed by SkywalkerT. In this game, she needs to find out hidden clues in the room to reveal a way to escape.

After a while, she realizes that the only way to run away is to open the digital door lock since she accidentally went into a secret compartment and found some clues, which can be interpreted as:

  • Only when you enter nn possible different passwords can you open the door;
  • Passwords must be integers ranged from 00 to (m−1)(m - 1);
  • A password cannot be xx (0≤x<m0 \leq x \lt m) if xx and mm are not coprime (i.e. xx and mm have some common divisor greater than 11);
  • A password cannot be xx (0≤x<m0 \leq x \lt m) if there exist non-negative integers ee and kk such that pe=km+xp^e = k m + x, where pp is a secret integer;
  • Any integer that doesn't break the above rules can be a password;
  • Several integers are hidden in the room, but only one of them can be pp.

Fortunately, she finds that nn and mm are recorded in the lock. However, what makes Tokitsukaze frustrated is that she doesn't do well in math. Now that she has found an integer that is suspected to be pp, she wants you to help her find out nn possible passwords, or determine the integer cannot be pp.

Tokitsukaze 正在玩一款由 SkywalkerT 设计的密室逃脱游戏。在该游戏中,她需要在房间中寻找隐藏线索,从而揭示逃脱的方法。

过了一段时间后,她意识到唯一的逃生方式是打开一扇数字门锁——因为她偶然进入了一个秘密隔间,并在那里发现了一些线索,这些线索可被解读为:

  • 只有当输入 nn 个互不相同的密码时,才能打开这扇门;
  • 密码必须是取值范围在 00 到 (m−1)(m - 1)(含端点)之间的整数;
  • 若整数 xx(其中 0≤x<m0 \leq x < m)与 mm 不互质(即 xx 与 mm 存在大于 11 的公因数),则 xx 不能作为密码;
  • 若存在非负整数 ee 和 kk,使得 pe=km+xp^e = k m + x(其中 pp 是某个未知的整数),则整数 xx(其中 0≤x<m0 \leq x < m)不能作为密码;
  • 任何不违反上述规则的整数均可作为密码;
  • 房间中隐藏着若干个整数,但其中仅有一个可能是 pp。

幸运的是,她发现锁上已记录了 nn 和 mm 的值。然而令 Tokitsukaze 感到沮丧的是,她的数学不太好。如今她找到了一个疑似为 pp 的整数,希望你能帮她找出 nn 个可能的密码;若该整数不可能是 pp,则请判定其不合法。

输入格式

The only line contains three integers nn, mm and pp (1≤n≤5×1051 \leq n \leq 5 \times 10^5, 1≤p<m≤10181 \leq p \lt m \leq 10^{18}).

It is guaranteed that mm is a positive integer power of a single prime number.

仅一行,包含三个整数 nn、mm 和 pp(1≤n≤5×1051 \leq n \leq 5 \times 10^5,1≤p<m≤10181 \leq p \lt m \leq 10^{18})。

保证 mm 是某个单一素数的正整数幂。

输出格式

If the number of possible different passwords is less than nn, print a single integer −1-1.

Otherwise, print nn distinct integers ranged from 00 to (m−1)(m - 1) as passwords. You can print these integers in any order. Besides, if there are multiple solutions, print any.

如果可能的不同密码数量少于 nn,则输出单个整数 −1-1。

否则,输出 nn 个互不相同的、取值范围为 00 到 (m−1)(m - 1) 的整数作为密码。这些整数的输出顺序可以任意。此外,若存在多个解,输出任意一个即可。

输入输出样例

  • 输入#1

    1 2 1

    输出#1

    -1
  • 输入#2

    3 5 1

    输出#2

    2 4 3
  • 输入#3

    2 5 4

    输出#3

    2 3
  • 输入#4

    4 9 8

    输出#4

    2 4 7 5

说明/提示

In the first example, there is no possible password.

In each of the last three examples, the given integer nn equals to the number of possible different passwords for the given integers mm and pp, so if the order of numbers in the output is ignored, the solution is unique as shown above.

在第一个例子中,不存在可能的密码。

在最后三个例子中,给定的整数 nn 等于对应整数 mm 和 pp 下可能的不同密码的数量,因此若忽略输出中数字的顺序,则如上所示,解是唯一的。

输入解题思路,AI测评打分。不知道怎么写?

首页