LeetCode Nim Game
来源:互联网 发布:mac baren烟丝购买 编辑:程序博客网 时间:2024/06/05 14:20
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.
Both of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.
For example, if there are 4 stones in the heap, then you will never win the game: no matter 1, 2, or 3 stones you remove, the last stone will always be removed by your friend.
class Solution(object): def canWinNim(self, n): """ :type n: int :rtype: bool """ if n % 4 ==0: return False return Trueif __name__ == '__main__': print Solution().canWinNim(5)
0 0
- Nim Game leetcode 292
- leetcode Nim Game
- [LeetCode 292] Nim Game
- leetcode | Nim Game
- leetcode 292---NIM GAME
- [leetcode] 292.Nim Game
- LeetCode:Nim Game
- leetcode-292-Nim Game
- LeetCode-Nim Game
- *LeetCode-Nim Game
- LeetCode Nim Game
- LeetCode之Nim Game
- 【Leetcode】Nim Game
- LeetCode 292----Nim Game
- LeetCode:Nim Game
- LeetCode -- Nim Game
- LeetCode--Nim Game
- [Leetcode] Nim Game
- Linux 学习总结 (四)
- 微信公众号开发-自定义菜单中链接用MUI前端框架写的网页以及发布到SAE服务器
- 关于SearchView的使用理解
- Linux操作系统十个注意事项
- Android Studio 百度地图定位、轨迹及所在位置与标注marker的距离
- LeetCode Nim Game
- label标签的二次点击事件
- LeetCode | Two Sum
- Delphi容器类之---TList、TObjectList、TComponentList、TClassList的使用
- 【闲聊】HUAWEI_Code_Craft sdk目录结构
- Oracle 11.2.0.4 expdp 含CLOB字段(basicfile)超级慢
- JVM笔记(二) 垃圾收集器(1)
- 【题解】 [HAOI2006]受欢迎的牛(强连通分量 tarjan)
- hdoj 1875 通畅工程再续 最小生成树