Trans
Time limit2sMemory limit512 MB
Given an array a of 2^n integers, compute for each i the sum of a_j over all j where popcount(i and j) is odd.
- Level
Medium5 of 10
- Topics
- Bit manipulation, Divide and conquer
- Solved
- No attempts yet
Statement
Bob is interested in popcount and some strange transforms. Currently, he is attacking the following problem:
There is an array of integers . For each (), calculate
where denotes the number of ones in the binary representation of , and denotes the bitwise AND operation.
Although Bob is very smart, he still can't solve the problem fast. Can you help him calculate all ?
Input
The first line contains a single integer ().
The second line contains integers describing the array ().
Output
Print one line with integers, the -th of them being the value .