#abc215d. D - Coprime 2

D - Coprime 2

Score : 400400 points

问题描述

给定一个包含 NN 个正整数的序列 A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N),找出满足以下条件的所有整数 kk,其范围在 11MM(包括两端点)之间:

  • 对于每一个满足 1iN1 \le i \le N 的整数 ii,有 gcd(Ai,k)=1\gcd(A_i,k)=1

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given a sequence of NN positive integers A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N), find every integer kk between 11 and MM (inclusive) that satisfies the following condition:

  • gcd(Ai,k)=1\gcd(A_i,k)=1 for every integer ii such that 1iN1 \le i \le N.

Constraints

  • All values in input are integers.
  • 1N,M1051 \le N,M \le 10^5
  • 1Ai1051 \le A_i \le 10^5

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 A2A_2 \dots ANA_N

Output

In the first line, print xx: the number of integers satisfying the requirement.
In the following xx 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, 77 has the properties gcd(6,7)=1,gcd(1,7)=1,gcd(5,7)=1\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, 99 has the property gcd(6,9)=3\gcd(6,9)=3, so it is not included in that set.
We have three integers between 11 and 1212 that satisfy the condition: 11, 77, and 1111. Be sure to print them in ascending order.

update @ 2024/3/10 09:32:51