#C14906. Divisible and Reversed

    ID: 44607 Type: Default 1000ms 256MiB

Divisible and Reversed

Divisible and Reversed

Given a list of integers and a positive integer \( n \), your task is to select all the numbers from the list that are divisible by \( n \) and output them in the reverse order of their appearance in the list.

For example, if the input list is [12, 4, 9, 10, 28, 45, 30] and \( n=3 \), since 12, 9, 45, and 30 are divisible by 3, the output should be [30, 45, 9, 12].

If no numbers in the list are divisible by \( n \), simply output nothing.

Input/Output Format: The input is read from stdin and the output is written to stdout.

inputFormat

The first line of input contains an integer \( m \) representing the number of elements in the list.

The second line contains \( m \) space-separated integers representing the list.

The third line contains the integer \( n \).

outputFormat

Output the filtered list of integers (those divisible by \( n \)) in reverse order. The numbers should be printed on one line separated by a space. If no such numbers exist, output nothing.

## sample
7
12 4 9 10 28 45 30
3
30 45 9 12

</p>