#x1080. Space Isaac
Space Isaac
Space Isaac
题面翻译
有0~m-1的数被分成了两个集合
每次你可以从两个集合中任取一个数做加法并对m取模
问最后0~m-1中不能被组合出来的数有多少个
会给出你A集合 大小不超过200000
m<=1e9
题目描述
Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is , for some positive integer . Ajs draws a number from the first bag and a number from the second bag, and then sums them modulo .
What are the residues modulo that Ajs cannot obtain with this action?
输入格式
The first line contains two positive integer ( ) and ( ), denoting the number of the elements in the first bag and the modulus, respectively.
The second line contains nonnegative integers ( ), the contents of the first bag.
输出格式
In the first line, output the cardinality of the set of residues modulo which Ajs cannot obtain.
In the second line of the output, print space-separated integers greater or equal than zero and less than , which represent the residues Ajs cannot obtain. The outputs should be sorted in increasing order of magnitude. If =0, do not output the second line.
样例 #1
样例输入 #1
2 5
3 4
样例输出 #1
1
2
样例 #2
样例输入 #2
4 1000000000
5 25 125 625
样例输出 #2
0
样例 #3
样例输入 #3
2 4
1 3
样例输出 #3
2
0 2
提示
In the first sample, the first bag and the second bag contain and , respectively. Ajs can obtain every residue modulo except the residue : $ 4+1 \equiv 0, \, 4+2 \equiv 1, \, 3+0 \equiv 3, \, 3+1 \equiv 4 $ modulo . One can check that there is no choice of elements from the first and the second bag which sum to modulo .
In the second sample, the contents of the first bag are , while the second bag contains all other nonnegative integers with at most decimal digits. Every residue modulo can be obtained as a sum of an element in the first bag and an element in the second bag.
相关
在下列比赛中: