Nim GameMy
来源:互联网 发布:沪昆高铁偷工减料知乎 编辑:程序博客网 时间:2024/06/06 03:48
Nim GameMy
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: return True return (n%4!=0)
看了https://leetcode.com/discuss/63978/one-line-o-1-solution-and-explanation之后的理解
0 0
- Nim GameMy
- nim
- Nim
- Nim
- Nim
- (博弈Nim)Nim
- POJ_2975 Nim(Nim)
- Nim游戏 Nim Game
- nim游戏
- [poj2975]Nim
- Nim游戏
- nim 博弈
- ZOJ3591 Nim
- NIM游戏
- 1.11 nim
- Nim游戏
- Nim游戏
- Nim 游戏
- 使用python对url编码解码
- 关系型数据库的理解
- 签到题
- 解决virtualbox只能安装32bit的问题
- hdu 5569(dp)
- Nim GameMy
- qml实现简单记事本程序
- Codeforces Round #333 Lipshitz Sequence 优先队列
- Java之Jacob调用COM接口DLL-----------------------------------dm。dll
- 跨浏览器的事件对象
- 真·为WordPress添加自机LaTeX支持(LaTeX for WordPress+MathJax)
- Linux僵尸进程
- hibernate学习笔记(一)hibernate应用背景(为什么要用hibernate)
- 数据结构之栈