City of Numbers, which had previously formed its city council, realized the…
- User
City of Numbers, which had previously formed its city council, realized the ineffectiveness of the council even if all of them were efficient. The people of the city now understand the need for a king and decide to elect a king.
But the problem is that people do not have the same opinion about the worthy person. More precisely, every person in the city of numbers has a number, and from the point of view of an individual with a number x Individual x with number y y better than someone with no Z z is if and only if y ⊕ x
Z ⊕ x y⊕x>z⊕x. That here is the meaning of the sign ⊕ ⊕ is the xor operation.
Now you will be given the numbers of the citizens of the city and say how many times each citizen will win in all situations of choosing two people and one judge. Note that the referee can also be a participant.
For a better understanding, you can refer to the sample description.
input In the first line n n is the number of citizens. In the next line n n number comes that i iamin them a i a i citizen number i i is 1 ≤ n ≤ 1000 , 000 1≤n≤1000,000 0 ≤ a i ≤ 1 0 9 0≤a i ≤10 9
output In the only output line is the number of advantages of people with optimal distance.
Example Sample entry 1 3 0 2 3 Plain text Sample output 1 4 2 3 Plain text Explanation of sample 1 [ ( 0 , 2 ) , 0 ] : 0 ⊕ 0 < 2 ⊕ 0 , w i n n e r :
2 [(0,2),0]:0⊕0<2⊕0,winner: 2 [ ( 0 , 3 ) , 0 ] : 0 ⊕ 0 < 3 ⊕ 0 , w i n n e r :
3 [(0,3),0]:0⊕0<3⊕0,winner: 3 [ ( 2 , 3 ) , 0 ] : 2 ⊕ 0 < 3 ⊕ 0 , w i n n e r :
3 [(2,3),0]:2⊕0<3⊕0,winner: 3 [ ( 0 , 2 ) , 2 ] : 0 ⊕ 2
2 ⊕ 2 , w i n n e r :
0 [(0,2),2]:0⊕2>2⊕2,winner: 0 [ ( 0 , 3 ) , 2 ] : 0 ⊕ 2
3 ⊕ 2 , w i n n e r :
0 [(0,3),2]:0⊕2>3⊕2,winner: 0 [ ( 2 , 3 ) , 2 ] : 2 ⊕ 2 < 3 ⊕ 2 , w i n n e r :
3 [(2,3),2]:2⊕2<3⊕2,winner: 3 [ ( 0 , 2 ) , 3 ] : 0 ⊕ 3
2 ⊕ 3 , w i n n e r :
0 [(0,2),3]:0⊕3>2⊕3,winner: 0 [ ( 0 , 3 ) , 3 ] : 0 ⊕ 3 < 3 ⊕ 3 , w i n n e r :
0 [(0,3),3]:0⊕3<3⊕3,winner: 0 [ ( 2 , 3 ) , 3 ] : 2 ⊕ 3
3 ⊕ 3 , w i n n e r :
2 [(2,3),3]:2⊕3>3⊕3,winner: 2
Sample input 2 5 0 0 1 4 5 Plain text Sample output 2 6 6 10 11 12 write in c++
- Assistant