Nim Game
来源:互联网 发布:皇室战争电磁炮数据 编辑:程序博客网 时间:2024/04/30 15:42
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.
bool canWinNim(int n) { return n % 4 != 0;}
0 0
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- Nim Game
- java连接数据库后进行更新插入操作
- AOP:JDK动态代理 vs CGLIB代理
- java deleteOnExit方法
- 欢迎使用CSDN-markdown编辑器
- 链表
- Nim Game
- Linux下find(文件查找)命令使用实例总结
- sp_spaceused (Transact-SQL) SP中涉及哪些表
- JS实现HTML静态页传值的方法
- 2016/8/23
- WordPress 3.6-4.5.2 Authenticated Revision History Information Disclosure
- 第九天:JAVA中的多态,抽象类和接口
- Maven项目中,将普通工程修改为web工程办法
- Error:Unable to start the daemon process.解决