#C12477. Primes Less Than Input Numbers

    ID: 41908 Type: Default 1000ms 256MiB

Primes Less Than Input Numbers

Primes Less Than Input Numbers

You are given a list of integers. For each integer ( x ), you need to output all prime numbers that are strictly less than ( x ) in increasing order. The primes should be printed as a space‐separated sequence on a separate line for each integer. To generate the list of primes efficiently, you may use the Sieve of Eratosthenes algorithm. For example, if the input number is 10, the output should be:

2 3 5 7

Note: If there are no primes less than the given number, output an empty line.

inputFormat

The input is read from standard input (stdin). The first line contains a single integer ( T ) representing the number of test cases. The second line contains ( T ) space-separated non-negative integers. Each integer ( x ) satisfies ( x \geq 0 ).

outputFormat

For each test case, print on a new line all prime numbers less than the given integer ( x ). The prime numbers should be printed in increasing order and separated by a single space. If no prime number exists for a given ( x ), output an empty line.## sample

1
10
2 3 5 7

</p>