luogu#P5080. Tweetuzki 爱序列
Tweetuzki 爱序列
Background
This problem is an adapted problem.
Problem Description
Tweetuzki has a sequence of length .
He wants to find the maximum such that there exist some numbers in the original sequence (not necessarily in the same order as in the original sequence), satisfying that for any , either (in this case, must be divisible by ) or . Output this sequence as well.
Input Format
The first line contains a positive integer , representing the length of the sequence.
The second line contains positive integers $a_1, a_2, \cdots, a_n(1 \le a_i \le 3 \times 10^{18})$, describing the sequence.
Output Format
The first line contains a positive integer , representing the maximum .
The second line contains positive integers , describing the numbers you chose.
6
4 8 6 3 12 9
6
9 3 6 12 4 8
4
42 28 84 126
4
126 42 84 28
5
4 8 16 12 24
4
12 24 8 16
Hint
Subtask #1 (20 points):;
Subtask #2 (30 points):;
Subtask #3 (20 points):;
Subtask #4 (30 points):。
Translated by ChatGPT 5