305516: CF1045B. Space Isaac
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
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 $ \{0,1,…,M-1\} $ , for some positive integer $ M $ . Ajs draws a number from the first bag and a number from the second bag, and then sums them modulo $ M $ . What are the residues modulo $ M $ that Ajs cannot obtain with this action?输入输出格式
输入格式
The first line contains two positive integer $ N $ ( $ 1 \leq N \leq 200\,000 $ ) and $ M $ ( $ N+1 \leq M \leq 10^{9} $ ), denoting the number of the elements in the first bag and the modulus, respectively. The second line contains $ N $ nonnegative integers $ a_1,a_2,\ldots,a_N $ ( $ 0 \leq a_1<a_2< \ldots< a_N<M $ ), the contents of the first bag.
输出格式
In the first line, output the cardinality $ K $ of the set of residues modulo $ M $ which Ajs cannot obtain. In the second line of the output, print $ K $ space-separated integers greater or equal than zero and less than $ M $ , which represent the residues Ajs cannot obtain. The outputs should be sorted in increasing order of magnitude. If $ K $ =0, do not output the second line.
输入输出样例
输入样例 #1
2 5
3 4
输出样例 #1
1
2
输入样例 #2
4 1000000000
5 25 125 625
输出样例 #2
0
输入样例 #3
2 4
1 3
输出样例 #3
2
0 2