Easy-11
来源:互联网 发布:2016中国网络影视峰会 编辑:程序博客网 时间:2024/06/03 05:09
leetcode 292. Nim Game
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.
AC:
bool canWinNim(int n) {
if((n-1)%4==0)
return true;
if((n-2)%4==0)
return true;
if((n-3)%4==0)
return true;
return false;
}
- Easy-11
- easy
- Easy
- Easy-题目11:169. Majority Element
- HDU ACM 11 2055 An easy problem
- Easy 11 Count and Say(38)
- LeetCode-Easy刷题(11) Maximum Subarray
- Install Firefox 11 in 5 easy steps on Linux
- Easy Plugs
- easy problem
- So Easy!
- so easy
- easy explorer
- Easy Explore
- Easy Task
- Easy Task
- Easy CHM
- HDU2699+Easy
- 分布式服务框架ZooKeeper:四字命令
- Java多线程学习
- Android游戏2048的实现
- redis cluster 与lua的结合使用
- .net C#实现登录界面并进行跳转
- Easy-11
- tld自定义标签之基础入门篇
- WinInet编程详解
- 开发单页应用(SPA)时候遇到的微信支付授权目录的坑
- 解决网络专线未开放80端口的问题
- swift——运算符——内置类型
- 第2章对象及变量的并发访问
- SQL笔记---删除重复数据,保留第一个
- spacemacs mysql连接管理