https://codeforces.com/problemset/problem/587/A So.i came across this problem,but i am not able to understand the logic behind the problem…any help’d be appreciated.

Now,it is okay,i guess

You need to use fact that 2^i + 2^i = 2^{i+1}

In the editorial,there is this line bit[i + 1] += bit[i]/2,can you please help me with this?

With this equation: 2^{i} + 2^{i} = 2^{i+1} We can say that half of 2^{i} can be used to make 2^{i+1} , We need to use floor division (or assign it to int).

so thats why bits[i+1] += bits[i]/2 //Half of prev to make 2^i+1