succession of non-negative integers a1,a2,… ,an is called developing if for all I from 1 to n−1 every one of the ones (of twofold portrayal) in man-made intelligence are in the spots of ones (of paired portrayal) in ai+1 (all in all, ai&ai+1=ai, where and indicates bitwise AND). In the event that n=1, the arrangement is viewed as developing too.
Detail code and output screenshot. Correct answer will upvoted else downvoted.
succession of non-negative integers a1,a2,… ,an is called developing if for all I from 1 to n−1 every one of the ones (of twofold portrayal) in man-made intelligence are in the spots of ones (of paired portrayal) in
For instance, the accompanying four groupings are developing:
[2,3,15,175] — in double it's [102,112,11112,101011112];
[5] — in paired it's [1012];
[1,3,7,15] — in paired it's [12,112,1112,11112];
[0,0,0] — in paired it's [02,02,02].
The accompanying three successions are non-developing:
[3,4,5] — in paired it's [112,1002,1012];
[5,4,3] — in paired it's [1012,1002,0112];
[1,2,4,8] — in paired it's [00012,00102,01002,10002].
Consider two successions of non-negative integers x1,x2,… ,xn and y1,y2,… ,yn. How about we call this pair of successions co-developing if the grouping x1⊕y1,x2⊕y2,… ,xn⊕yn is developing where ⊕ indicates bitwise XOR.
You are given a succession of integers x1,x2,… ,xn. Discover the lexicographically insignificant succession y1,y2,… ,yn to such an extent that groupings xi and yi are co-developing.
The grouping a1,a2,… ,an is lexicographically more modest than the succession b1,b2,… ,bn if there exists 1≤k≤n with the end goal that ai=bi for any 1≤i<k however ak<bk.
Input :The main line contains an integer t (1≤t≤104). Then, at that point, t experiments follow. The main line of each experiment contains an integer n (1≤n≤2⋅105) — length of the succession xi. The subsequent line contains n integers x1,x2,… ,xn (0≤xi<230) — components of the grouping xi. It is ensured that the amount of n by and large all experiments doesn't surpass 2⋅105.
Output :For each experiment, print n integers y1,y2,… ,yn (0≤yi<230) — lexicographically negligible grouping to such an extent that to such an extent that it's co-developing with given arrangement xi.
Step by step
Solved in 4 steps with 1 images