CF1176D.Recover it!
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Authors guessed an array a consisting of n integers; each integer is not less than 2 and not greater than 2⋅105 . You don't know the array a , but you know the array b which is formed from it with the following sequence of operations:
- Firstly, let the array b be equal to the array a ;
- Secondly, for each i from 1 to n :
- if ai is a prime number, then one integer pai is appended to array b , where p is an infinite sequence of prime numbers ( 2,3,5,… );
- otherwise (if ai is not a prime number), the greatest divisor of ai which is not equal to ai is appended to b ;
- Then the obtained array of length 2n is shuffled and given to you in the input.
Here pai means the ai -th prime number. The first prime p1=2 , the second one is p2=3 , and so on.
Your task is to recover any suitable array a that forms the given array b . It is guaranteed that the answer exists (so the array b is obtained from some suitable array a ). If there are multiple answers, you can print any.
输入格式
The first line of the input contains one integer n ( 1≤n≤2⋅105 ) — the number of elements in a .
The second line of the input contains 2n integers b1,b2,…,b2n ( 2≤bi≤2750131 ), where bi is the i -th element of b . 2750131 is the 199999 -th prime number.
输出格式
In the only line of the output print n integers a1,a2,…,an ( 2≤ai≤2⋅105 ) in any order — the array a from which the array b can be obtained using the sequence of moves given in the problem statement. If there are multiple answers, you can print any.
输入输出样例
输入#1
3 3 5 2 3 2 4
输出#1
3 4 2
输入#2
1 2750131 199999
输出#2
199999
输入#3
1 3 6
输出#3
6