1's Complement
Basic Accuracy: 49.4% Submissions: 2564 Points: 1

Given an N bit binary number, find the 1's complement of the number. The ones' complement of a binary number is defined as the value obtained by inverting all the bits in the binary representation of the number (swapping 0s for 1s and vice versa).

Input:

The first line of input takes an integer T, the number of test cases. Then T test cases follow. The first line of each test case takes an integer N, the number of bits. The second line of each test case takes N space separated integers denoting the N bits of the binary number.

Output:

Print the 1's complement for each test case in a new line.

Constraints:
1<=T<=100

1<=N<=100

Example:
Input:

3
2
1 0
2
1 1
3
1 0 1

Output:
0 1
0 0 0 1 0

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.