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:


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]
regardless then add occur[i]C2 to occur[i+1]
take mod at all steps to prevent overflow;
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.