Subsequence Divisibility

Pages: 123
@kashish
thanks for help,
what is vthis value and how to print large pow(10,n-x-1) still confused:(
Last edited on
.
Last edited on
@kashish thanks for help. you are awesome.
@kashish

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.

can you explain why output is 0 ?
Last edited on
Thanks@ipg2016069 you are also awesome.
Last edited on
@kashish i don't understand your hint
@kashish
in magic set
if n=3 and m=3
and array is {1,2,3} then what is output ?

the following subsequences of array is:
{1},{1,2}, {1,2,3},{2}, {2,3} ,{3}. is it right ?
Last edited on
@helpinghand there is diffrence between subarray and subsequence. ?
https://www.geeksforgeeks.org/sum-of-all-subarrays/
@kashish ??
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.
@ipg 2016069
Don't share your code.If anyone submit it without changing it more than 30% you will get palgirsm
i did it. @kashish thanks for help me.
Last edited on
Those who are not getting just focus only on the number which are divisible by m.
@ipg 2,3,5,6,9 so we can take 3,6,9 or only 6,9 ?
we have to take it sequentially or randomly
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).
Last edited on
@ipg check your PM please help.
Everyone still suffering try using long long for your end result.. for MGCSET
No i got that answer right
Last edited on
Is there a forum for No Strings Attached?
Pages: 123