#C14724. Reversed Binary Conversion

    ID: 44405 Type: Default 1000ms 256MiB

Reversed Binary Conversion

Reversed Binary Conversion

You are given a list of non-negative integers. For each integer, convert it to its binary representation (without the prefix 0b), then reverse the binary string. If any integer in the input is negative, output ValueError instead of processing the list.

More formally, given an integer \(n \ge 0\), let its binary representation be \(b(n)\) (with no leading zeros unless the number is 0). The answer is the string \(b(n)^R\) which is the reverse of \(b(n)\). If the input list is \(L = [a_1, a_2, \dots, a_k]\), then the output should be a list \(R = [b(a_1)^R, b(a_2)^R, \dots, b(a_k)^R]\). However, if any \(a_i < 0\), then the program should output ValueError and terminate.

Note: All formulas are given in \(\LaTeX\) format. For example, converting \(2\) gives binary "10", and reversing it gives "01".

inputFormat

The input is given via stdin and it contains two lines:

  1. The first line contains a single integer \(n\) (the number of integers in the list).
  2. The second line contains \(n\) space-separated integers.

outputFormat

If all numbers are non-negative, print the reversed binary representations of each number separated by a single space to stdout. If any number is negative, print ValueError to stdout.

## sample
3
2 3 4
01 11 001