P5736 [Deep Base 7.Example 2] Prime Sieve
Description
Input $n$ positive integers, each not greater than $10^5$. Store them all in an array, remove the numbers that are not prime, and output the remaining primes in order.
Input Format
The first line contains a positive integer $n$, indicating the number of integers.
The second line contains $n$ positive integers $a_i$, separated by spaces.
Output Format
Output one line: print the remaining primes in $a_i$ in order, separated by spaces.
Explanation/Hint
Constraints: $1 \le n \le 100$, $1 \leq a_i \leq 10^5$.
Translated by ChatGPT 5