Please solve the question!

Just Check Other’s codes if you are not able to come up with a solution.Why do you need us to solve it?

Other people’s code tends to be utterly undecipherable and usually gives no clue as to the high-level approach/ logic behind it - which is why Problems should always have an Editorial :slight_smile:

5 Likes

input a [n]&b
sort a
find number of occurences of each value ans store in int occur[64]
convert b to binary
as bool b[64];
check if(bool[i]==1)
then ans=ansoccur[i]
occur[i]–
regardless then add occur[i]C2 to occur[i+1]
repeat
take mod at all steps to prevent overflow;
explanation
ans=ans
occur[i] because thats how many ways we can choose that power
we add occur[i]C2 because any pair can also be used to get the same sum.