Help in pairwise AND

hello guys can you help with this : CodeChef: Practical coding for everyone

try to solve the problem for n= 1, 2, 4, 8, 16, …
if you have the answer using only X bits, can you find the solution for X+1 bits?

If this helps.

1 Like

if you look the binary representation for N=29, you can see that a bit 1 with an adjacent bit 1 appear periodically. You can use that to count the active bits in the i-th collumn and multiply by 2^i.

my solution: https://www.codechef.com/viewsolution/44318769