focus only on the number which are divisible by m.
https://www.codechef.com/JULY18B/problems/MGCSET
in Magic Set question
if N=2 and array is {1,2}
then subsequences are {1}, {2}, {1,2} then in sample test case 1:
1
2 3
1 2
output is 0 but there is one subsequences {1,2} sum is divisible by m(m==3). so output should be 1 instead of 0.
ipg 2016069
You have not read the problem statement carefully.In the problem statment
She defines a good sequence of integers as a non-empty sequence such that the sums of all its non-empty subsequences are divisible by m.
Read this statment carefully.
if N=2 and array is {1,2}.Value of M=3.
then subsequences are {1}, {2}, {1,2}
Sum of subsequence {1,2} is divisible by M but the sub-sequence of this sequence those are({1},{2}) are not divisible by M.That's why answer is 0.
count the no. of element of which is divisible by m , let's say x. and then just print the 2^x-1 that's the answer.
for ex 2,3,5,6,9 and m=3 then 3,6,9 (x=3) so ans is 2^3-1 (==7).