#C13440. Divisible Array Elements
Divisible Array Elements
Divisible Array Elements
You are given an array of integers and an integer n. Your task is to print all elements of the array that are divisible by n.
Note: If no element in the array is divisible by n, output -1.
Example:
Input: 4 2 4 6 8 2</p>Output: 2 4 6 8
In the example above, every element of the array [2, 4, 6, 8] is divisible by 2, so the resulting output is "2 4 6 8".
inputFormat
The input consists of three lines:
- The first line contains an integer T representing the number of elements in the array.
- If T > 0, the second line contains T space-separated integers denoting the array elements. If T = 0, the second line will be empty.
- The third line contains an integer n, the divisor.
outputFormat
If there exists at least one element in the array that is divisible by n, print these elements separated by a single space. Otherwise, print -1.
## sample4
2 4 6 8
2
2 4 6 8