

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 400 点
問題文
長さ N の正整数列 A=(A_1,A_2,\dots,A_N) が与えられるので、以下の条件を満たす 1 以上 M 以下の整数 k を全て求めてください。
- 全ての 1 \le i \le N を満たす整数 i について、 \gcd(A_i,k)=1 である。
制約
- 入力は全て整数
- 1 \le N,M \le 10^5
- 1 \le A_i \le 10^5
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 A_2 \dots A_N
出力
1 行目に、出力する整数の数 x を出力せよ。
続く x 行に、答えとなる整数を小さい方から順に 1 行に 1 つずつ出力せよ。
入力例 1
3 12 6 1 5
出力例 1
3 1 7 11
例えば、 7 は \gcd(6,7)=1,\gcd(1,7)=1,\gcd(5,7)=1 を満たすので答えとなる整数の集合に含まれます。
一方、 9 は \gcd(6,9)=3 となるため、答えとなる整数の集合に含まれません。
条件を満たす 1 以上 12 以下の整数は 1,7,11 の 3 つです。これらを小さい方から出力することに注意してください。
Score : 400 points
Problem Statement
Given a sequence of N positive integers A=(A_1,A_2,\dots,A_N), find every integer k between 1 and M (inclusive) that satisfies the following condition:
- \gcd(A_i,k)=1 for every integer i such that 1 \le i \le N.
Constraints
- All values in input are integers.
- 1 \le N,M \le 10^5
- 1 \le A_i \le 10^5
Input
Input is given from Standard Input in the following format:
N M A_1 A_2 \dots A_N
Output
In the first line, print x: the number of integers satisfying the requirement.
In the following x lines, print the integers satisfying the requirement, in ascending order, each in its own line.
Sample Input 1
3 12 6 1 5
Sample Output 1
3 1 7 11
For example, 7 has the properties \gcd(6,7)=1,\gcd(1,7)=1,\gcd(5,7)=1, so it is included in the set of integers satisfying the requirement.
On the other hand, 9 has the property \gcd(6,9)=3, so it is not included in that set.
We have three integers between 1 and 12 that satisfy the condition: 1, 7, and 11. Be sure to print them in ascending order.