CF772C.Vulnerable Kerbals

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given an integer mm , and a list of nn distinct integers between 00 and m1m-1 .

You would like to construct a sequence satisfying the properties:

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

Construct any sequence satisfying the properties above.

输入格式

The first line of input contains two integers nn and mm ( 0<=n<m<=200000 ) — the number of forbidden prefix products and the modulus.

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

输出格式

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

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

输入输出样例

  • 输入#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 mm are [1,2,3,4,0][1,2,3,4,0] .

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

首页