Why i am getting wrong answer?

https://www.codechef.com/JULY18B/problems/MGCSET
https://ide.codingblocks.com/#/s/16531

Hi Amritanshu, this is a live contest problem so you should try to do this on your own. We can discuss things when the contest is over :relaxed:

Can you atleast provide some test cases where i’m going wrong?

for the 1st testcast
2 3
1 2
output
0
why ?
as subsequences are {1},{2},{1,2}
for {1,2} sum=3 which is divisible by 3
so output should be 1

She defines a good sequence of integers as a non-empty sequence such that the sum of the elements in each of its non-empty subsequences is divisible by m.

Since for [1, 2], non-empty subsequences are [1], [2], and [1 2] and only the last one divisible by 3 not the other two, it is not a good sequence. Sequence like [3 6 12] is a good one since [3], [6], [12], [3 6], [6 12], [3 12] all have sums divisible by 3.

Thanks a lot for your help. My code got accepted:smile:

1 Like