首页 > 其他 > 详细

LeetCode 292. Nim Game

时间:2016-05-17 00:32:26      阅读:218      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!