码迷,mamicode.com
首页 > 其他好文 > 详细

LeetCode 292. Nim Game

时间:2016-05-17 00:34:47      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

https://leetcode.com/problems/nim-game/

经典博弈,数学归纳法。

技术分享
 1 #include <iostream>
 2 using namespace std;
 3 
 4 class Solution {
 5 public:
 6     bool canWinNim(int n) {
 7         return (n % 4 != 0);
 8     }
 9 };
10 
11 int main ()
12 {
13     Solution testSolution;
14     bool result = false;
15     
16     result = testSolution.canWinNim(1);    
17 
18     cout << result << endl;
19     
20     char ch;
21     cin >> ch;
22     
23     return 0;
24 }
View Code

 

LeetCode 292. Nim Game

标签:

原文地址:http://www.cnblogs.com/pegasus923/p/5499939.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!