我想知道是否有一种简单的方法可以在这里看到这种模式。我已经考虑了好几个小时,但无法完全制定它。
游戏的运作方式是有 2 个玩家,N
石头塔,当轮到玩家时,他必须从塔中移除至少 1 块石头,移除最后一块石头的玩家获胜。
这是我到目前为止绘制的内容,作为获胜者的塔高度地图:
// {1} ---> "First" (remove the single stone)
// {2} ---> "First" (remove both stones)
// {n}, n > 2 ---> "First" (remove all the stones)
// {1, 1} ---> "Second" (because your only option is to remove 1 stone and then your opponent only has to remove 1 stone to win)
// {1, 2} ---> "First" (because you can remove 1 stone from the 2nd tower and then your opponent is left with {1, 1} which makes him lose as I explained in the last one)
// {1, 3} ---> "First"
// {1, n}, n > 1 ---> "First"
// {2, 2} ---> "Second"
// {2, 3} ---> "First"
// {2, 4} ---> "First"
// {2, n}, n > 2 ---> "First"
// {m, n} ---> m < n ---> "First"
// {1, 1, 1} ---> "First"
// {1, 1, 2} ---> "First"
// {1, 1, 3} ---> "First"
// {1, 1, n} ---> "First"
// {1, 2, 2} ---> "First"
// {1, 2, 3} ---> "Second"
// {1, 2, 4} ---> "First"
// {1, 2, 5} ---> "First"
// {1, 2, n}, n > 3 ---> "First"
// {2, 2, 2} ---> "First"
// {2, 2, 3} ---> "First"
// {2, 2, n}, n > 1 ---> "First"
我得出的事实:
- 如果每座塔有1个石头,如果塔数为奇数,则轮到的玩家获胜,否则输
- 如果塔的数量是
N
并且任何塔的高度大于N+1
,则结果与该塔的高度相同N+1
除此之外,我想不出足够的模式来编写线性解决方案。
有什么帮助吗?