All TCs giving WA in game theory - 3 problem

my sol : https://ide.codingblocks.com/s/268337

can u pls tell me where my code is going wrong and whether my approach is correct or not

according to me above code should run fine !

@saarthakseth
there are few mistakes in your code. I am pointing out them

  1. list of divisors must also contain 1, so start g=1 in line 10
  2. declare ll m[n] array outside while() loop. it is taking too much memory.
  3. There is mistake in your grundy() function. i have made changes in your code. check the given link https://ide.codingblocks.com/s/278524

but it is given in the ques that B > 1 ,i.e B can’t be = 1

so the list of divisors shouldn’t contain 1

can u pls explain why did u make those changes and how the changes will effect the code ??