Subsequence Divisibility

Pages: 123
Jul 7, 2018 at 9:56am
@kashish
thanks for help,
what is vthis value and how to print large pow(10,n-x-1) still confused:(
Last edited on Jul 7, 2018 at 9:57am
Jul 7, 2018 at 9:58am
.
Last edited on Jul 7, 2018 at 3:11pm
Jul 7, 2018 at 10:06am
@kashish thanks for help. you are awesome.
Jul 7, 2018 at 10:11am
@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 Jul 7, 2018 at 10:15am
Jul 7, 2018 at 10:12am
Thanks@ipg2016069 you are also awesome.
Last edited on Jul 7, 2018 at 10:13am
Jul 7, 2018 at 10:14am
@kashish i don't understand your hint
Jul 7, 2018 at 10:24am
@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 Jul 7, 2018 at 10:26am
Jul 7, 2018 at 10:48am
Jul 7, 2018 at 10:58am
@helpinghand there is diffrence between subarray and subsequence. ?
https://www.geeksforgeeks.org/sum-of-all-subarrays/
Jul 7, 2018 at 11:44am
@kashish ??
Jul 7, 2018 at 11:48am
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.
Jul 7, 2018 at 11:50am
@ipg 2016069
Don't share your code.If anyone submit it without changing it more than 30% you will get palgirsm
Jul 7, 2018 at 12:42pm
i did it. @kashish thanks for help me.
Last edited on Jul 7, 2018 at 12:43pm
Jul 7, 2018 at 12:44pm
Those who are not getting just focus only on the number which are divisible by m.
Jul 7, 2018 at 1:43pm
@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
Jul 7, 2018 at 1:55pm
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 Jul 7, 2018 at 1:57pm
Jul 7, 2018 at 1:59pm
@ipg check your PM please help.
Jul 7, 2018 at 3:13pm
Everyone still suffering try using long long for your end result.. for MGCSET
Jul 7, 2018 at 7:11pm
No i got that answer right
Last edited on Jul 7, 2018 at 7:11pm
Jul 9, 2018 at 6:56pm
Is there a forum for No Strings Attached?
Pages: 123