LeetCode: 292 Nim Game(easy)
2024-08-30 13:19:04
题目:
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.
Credits:
Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.
代码:
class Solution {
public:
bool canWinNim(int n) {
return (n% != );
}
};
最新文章
- poj 2155:Matrix(二维线段树,矩阵取反,好题)
- 实时获取UITextField内容
- Phonegap项目中禁用WebViewBounce
- 使用MySQL Proxy解决MySQL主从同步延迟
- 【转】QT中QWidget、QDialog及QMainWindow的区别
- LED汽车前大灯
- supersocket--SuperSocket 1.4系列文档(1) 第一个例子, EchoService
- ZLG_GUI和3D显示的移植
- ThreadGroup详解
- 淘宝NPM源的使用
- vue2 vue-router 组装
- shell脚本中关于getopts的使用方法
- 驰骋工作流引擎JFlow与activiti的对比之4种高级分支同步模式
- node中间层转发请求
- wxformbuilder在python如何使用
- docker资料---添加阿里docker加速镜像
- 【BZOJ3507】通配符匹配(哈希,动态规划)
- 程序员面试50题—sizeof的用法(6)
- expect 交互 之双引号较长变量
- CI框架 -- 配置文件config.php