#C4712. Filter Divisible Elements

    ID: 48281 Type: Default 1000ms 256MiB

Filter Divisible Elements

Filter Divisible Elements

You are given a list of integers and an integer divisor \(d\). Your task is to filter out and output a new list that contains only those elements in the list which are divisible by \(d\). The output should be displayed in the exact list format: [a, b, c, ...].

If \(d = 0\), your program should not attempt to perform division. Instead, it should raise a ZeroDivisionError (or its equivalent in your chosen language) by printing the message "ZeroDivisionError".

Note: The input will be provided via standard input and the output should be printed to standard output.

inputFormat

The input consists of three lines:

  • The first line contains an integer \(n\), representing the number of elements in the list.
  • The second line contains \(n\) space-separated integers.
  • The third line contains an integer \(d\), the divisor.

outputFormat

Output a single line containing the filtered list in the format: [x, y, z, ...]. If \(d = 0\), output ZeroDivisionError.

## sample
4
3 6 9 12
3
[3, 6, 9, 12]