We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
/* * Complete the 'misereNim' function below. * * The function is expected to return a STRING. * The function accepts INTEGER_ARRAY s as parameter. * Refer to: https://mathoverflow.net/questions/71802/analysis-of-misere-nim */stringmisereNim(vector<int>s){intn=s.size(),xr=0;boolgreat=false;for(autoi:s){xr^=i;if(i>1)great=true;}// Refer to: https://mathoverflow.net/questions/71802/analysis-of-misere-nim// (1) or (2)// (1) having some s[i] greater than 1 and xor of all s[i] == 0// (2) all s[i] <= 1 (as the constraint "1 <= s[i] <= 10^9" of this problem, then all s[i] == 1) and xor of all s[i] == 1; then second player will win;if((xr==0&&great==true)||(xr==1&&great==false))return"Second";return"First";}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Misère Nim
You are viewing a single comment's thread. Return to all comments →
detailed solution