my code=https://ide.codingblocks.com/s/474842
Why did not my code work.
I saw the discussins and find out the correct approach=
In the correct approach why have they used j<22
pplz explain
my code=https://ide.codingblocks.com/s/474842
Why did not my code work.
I saw the discussins and find out the correct approach=
In the correct approach why have they used j<22
pplz explain
…
all u r checking is whether the total sum is even or not.
but not all even number can be a represented as power of 2. for example-> 14 u cant represrent this as power of two.
look at the constraints they have said that maximum value of delicioness can be 2^20. so if u add two such number then u may get total sum upto 2^21.
that is the reason why they are iterating till j < 22 (ie j<=21) , to generate all power of 2 (from 2^0 to 2^21)
ok thanku so much 
In the code how the beow lines are ensuring that the only those nos are taken which sum upto any power of 4
m[s-a[i]];
s=s*2;
…
note s. s is only having power of 2 right? becuase we are always multiplying s by 2 . so initially it will be 1 then 2 then 2^2 then 2^3 then 2^4 so on.
now
look at this line. here a[i] is the current element and we want to form s. that means another number that we are needed is s-a[i]
that is why we are using m[s-a[i]] this will give how many times number (s-a[i]) occured
thank u so much 
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.