CF772C.Vulnerable Kerbals

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given an integer m, and a list of n distinct integers between 0 and m - 1.

You would like to construct a sequence satisfying the properties:

  • Each element is an integer between 0 and m - 1, inclusive.
  • All prefix products of the sequence modulo m are distinct.
  • No prefix product modulo m appears as an element of the input list.
  • The length of the sequence is maximized.

Construct any sequence satisfying the properties above.

给你一个整数 mm,以及一个包含 nn 个互不相同的整数的列表,这些整数均在 00 到 m−1m-1 之间(含端点)。

你希望构造一个满足以下性质的序列:

  • 序列中每个元素均为 00 到 m−1m-1(含端点)之间的整数;
  • 序列的所有前缀积对 mm 取模的结果互不相同;
  • 任意前缀积对 mm 取模的结果均不出现在给定的输入列表中;
  • 序列的长度尽可能长。

请构造出任意一个满足上述性质的序列。

输入格式

The first line of input contains two integers n and m (0 ≤ n < m ≤ 200 000) — the number of forbidden prefix products and the modulus.

If n is non-zero, the next line of input contains n distinct integers between 0 and m - 1, the forbidden prefix products. If n is zero, this line doesn't exist.

输入的第一行包含两个整数 nn 和 mm(0 ≤ n < m ≤ 200 0000 \leq n < m \leq 200\,000)—— 分别表示禁止的前缀积个数和模数。

若 nn 非零,则输入的下一行包含 nn 个互不相同的整数,取值范围为 00 到 m−1m-1,表示禁止的前缀积;若 n=0n = 0,则该行不存在。

输出格式

On the first line, print the number k, denoting the length of your sequence.

On the second line, print k space separated integers, denoting your sequence.

第一行输出一个整数 kk,表示你构造的序列的长度。

第二行输出 kk 个用空格分隔的整数,表示你构造的序列。

输入输出样例

  • 输入#1

    0 5

    输出#1

    5
    1 2 4 3 0
  • 输入#2

    3 10
    2 9 1

    输出#2

    6
    3 9 2 9 8 0

说明/提示

For the first case, the prefix products of this sequence modulo m are [1, 2, 3, 4, 0].

For the second case, the prefix products of this sequence modulo m are [3, 7, 4, 6, 8, 0].

对于第一种情况,该序列对 mm 取模后的前缀积为 [1, 2, 3, 4, 0]。

对于第二种情况,该序列对 mm 取模后的前缀积为 [3, 7, 4, 6, 8, 0]。

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

首页