You are viewing a single comment's thread. Return to all comments →
Finally, got this using grundy numbers again. This is little complicated due to long numbers required for N and factors. Grundy numbers are still integers only. Also two of the test cases failed initially forcing me to use a Map for storing the grundy numbers during calculation. That solved all the test cases.