题目:

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% != );
}
};

最新文章

  1. poj 2155:Matrix(二维线段树,矩阵取反,好题)
  2. 实时获取UITextField内容
  3. Phonegap项目中禁用WebViewBounce
  4. 使用MySQL Proxy解决MySQL主从同步延迟
  5. 【转】QT中QWidget、QDialog及QMainWindow的区别
  6. LED汽车前大灯
  7. supersocket--SuperSocket 1.4系列文档(1) 第一个例子, EchoService
  8. ZLG_GUI和3D显示的移植
  9. ThreadGroup详解
  10. 淘宝NPM源的使用
  11. vue2 vue-router 组装
  12. shell脚本中关于getopts的使用方法
  13. 驰骋工作流引擎JFlow与activiti的对比之4种高级分支同步模式
  14. node中间层转发请求
  15. wxformbuilder在python如何使用
  16. docker资料---添加阿里docker加速镜像
  17. 【BZOJ3507】通配符匹配(哈希,动态规划)
  18. 程序员面试50题—sizeof的用法(6)
  19. expect 交互 之双引号较长变量
  20. CI框架 -- 配置文件config.php

热门文章

  1. 通过路由管理视图间切换 - AngularJS路由解析
  2. IntelliJ IDEA配置Tomcat及部署项目
  3. mysql "ON DUPLICATE KEY UPDATE" 语法
  4. node开发后将本地mysql数据导入到服务器mysql
  5. EasyDarwin云存储方案调研:海康萤石云采用的是MPEG-PS打包的方式进行的存储
  6. spring 监听器简介
  7. linux socket详解
  8. HBase开发
  9. Masonry库的使用
  10. 浅淡!important对CSS的重要性