304015: CF772C. Vulnerable Kerbals
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Vulnerable Kerbals
题意翻译
给出m,n,再给一个m个数的集合让你构造一个序列满足以下的条件: 1.这个序列的所有数都在0-m-1之间(含) 2.这个数列的所有前缀积都不同 3.所有的前缀积都不能出现在给你的集合中 4.最大化这个序列的长度 输出任意满足条件的序列。题目描述
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.输入输出格式
输入格式
The first line of input contains two integers $ n $ and $ m $ ( $ 0<=n<m<=200000 $ ) — 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.
输出格式
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.
输入输出样例
输入样例 #1
0 5
输出样例 #1
5
1 2 4 3 0
输入样例 #2
3 10
2 9 1
输出样例 #2
6
3 9 2 9 8 0