PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000122. Liệt kê số nguyên tố cùng nhau (Coprime 2)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Liệt kê số nguyên tố cùng nhau (Coprime 2)
Coprime 2
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers and a positive integer , list every integer in such that for every . Print the valid integers in increasing order.
Input
The first line contains . The second contains numbers .
Output
Print the count on the first line. On each of the next lines, print one valid number in ascending order.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
3 12
6 1 5
Output
3
1
7
11
Explanation
Among integers from 1 to 12, only 1, 7 and 11 are coprime to all of 6, 1 and 5. For instance, 9 is excluded because .