Pls give some hint and explain the question

@harry_potter123 hey ,First calculate total powers of all prime number in array. For example - in array [3 18 2 2] total powers of 2 will be 3 and powers of 3 will be 3. Now let me try to relate this problem with a classical game theory problem.

Let prime numbers are piles of stones and their total prime powers in array are equivalent to respective piles size. Now this has become a problem where two players are playing optimally and they reduce every pile to size 0. The last player unable to move loses.

Read over internet about NIM game

i learnt sprague grundy but i am not getting how the ans for sample test case are coming

for testcase 2 i calculated g(18)=3 g(2)=1 g(2)=1 g(3)=1 taking xor 3^1^1^1 !=0 so first person should win but ans is second player how?

@harry_potter123 hey pls read about NIM game you will get it as this is the logic behind question.