早教吧 育儿知识 作业答案 考试题库 百科 知识分享

我遇到了一个难题,是一道ACM题目Nimisamathematicalgameofstrategyinwhichtwoplayerstaketurnsremovingobjectsfromdistinctheaps.Oneachturn,aplayermustremoveatleastoneobject,andmayremoveanynumberofobjectsprovided

题目详情
我遇到了一个难题,是一道ACM题目
Nim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps.On each turn,a player must remove at least one object,and may remove any number of objects provided they all come from the same heap.Here is another version of Nim game.There are N piles of stones on the table.Alice first chooses some CONSECUTIVE piles of stones to play the Nim game with Tom.Also,Alice will make the first move.Alice wants to know how many ways of choosing can make her win the game if both players play optimally.
You are given a sequence a[0],a[1],...a[N-1] of positive integers to indicate the number of stones in each pile.The sequence a[0]...a[N-1] of length N is generated by the following code:
\x05
\x05
int g = S;
for (int i=0; i1);
}
else
{
g = (g>>1) ^ W;
}
ma=0;
for(j=i;j>=0;j--)
{
ma=ma^a[j];
if(ma)
sum++;
}
}
printf("%d\n",sum);
}
return 0;
}
会超时,
链接
▼优质解答
答案和解析
你吧题目的主要意思说一下,我帮你写.去年参赛的我们组有专门翻译的.嘻嘻!