Leetcode 292. Nim Game (Easy) (cpp)
2016-10-18 13:52
316 查看
Leetcode 292. Nim Game (Easy) (cpp)
Tag: Brainteaser
Difficulty: Easy
这是一道locked题目,给评论个“赞”呗?
Tag: Brainteaser
Difficulty: Easy
这是一道locked题目,给评论个“赞”呗?
/* 292. Nim Game (Easy) 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. Hint: If there are 5 stones in the heap, could you figure out a way to remove the stones such that you will always be the winner? */ class Solution { public: bool canWinNim(int n) { return n % 4; } };
相关文章推荐
- 菜鸟写给菜鸟的 ——LeetCode解题笔记 Easy-题目1:292. Nim Game
- [LeetCode]-292. Nim Game(Easy)(C + 尼姆游戏)
- Leetcode 293. Flip Game (Easy) (cpp)
- LeetCode [292. Nim Game] 难度[easy]
- [leetcode][easy]292. Nim Game
- leetcode(75).292. Nim Game
- Leetcode 292. Nim Game
- leetcode-292. Nim Game
- Leetcode 217. Contains Duplicate (Easy) (cpp)
- Leetcode 299. Bulls and Cows (Easy) (cpp)
- Leetcode 237. Delete Node in a Linked List (Easy) (cpp)
- Leetcode 67. Add Binary (Easy) (cpp)
- Leetcode 389. Find the Difference (Easy) (cpp)
- leetcode 292. Nim Game 题解
- LeetCode 292. Nim Game
- Leetcode 102. Binary Tree Level Order Traversal (Easy) (cpp)
- Leetcode 226. Invert Binary Tree (Easy) (cpp)
- Leetcode 397. Integer Replacement (Easy) (cpp)
- LeetCode *** 292. Nim Game
- [leetcode]292. Nim Game