public class Solution {
public bool CanWinNim(int n) {
//如果要赢,最后3个必须是自己来拿 //也就是最后剩1,2,3是胜利, //如果剩4枚,则必输, //如果剩5,6,7枚,则只需要拿完这次,剩下4枚,则必胜, //如果剩8枚,则必输, //如果剩9,10,11,则只需拿完这次,剩下8枚,则必胜, //如果剩12枚,则必输 //可总结出规律,初试石头数量,是4或者4的倍数,则必输
if (n % == )
{
return false;
}
else
{
return true;
}
}
}

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

leetcode292的更多相关文章

  1. LeetCode292:Nim Game

    You are playing the following Nim Game with your friend: There is a heap of stones on the table, eac ...

  2. [Swift]LeetCode292. Nim游戏 | Nim Game

    You are playing the following Nim Game with your friend: There is a heap of stones on the table, eac ...

  3. LeetCode 292

    Nim Game You are playing the following Nim Game with your friend: There is a heap of stones on the t ...

随机推荐

  1. freemarker在js中的应用

    <script type="text/javascript"> //freemarker在js中的应用: var newOrganizations = []; < ...

  2. adnanh webhook 框架execute-command 以及参数传递处理

      adnanh webhook是一个很不错的webhook 实现,方便灵活. adnanh webhook 支持以下功能: 接收请求 解析header 以及负载以及查询变量 规则检查 执行命令 下面 ...

  3. oracle 获取星期日期

    oracle 中的计算如下: 计算本星期的起始结束日期--得到星期一的日期select trunc(sysdate,''DD'')-to_char(sysdate,''D'')+2 from dual ...

  4. JS替换空格回车换行符

    JS替换空格回车换行符 str=str.replace(/\r/g," ") str=str.replace(/\n/g,"<br />")  或 ...

  5. es6比es5节省代码的地方总结

    对象方法简写: es5写法: var obj = { name: 'jeff', getName: function () { return this.name; } } es6写法(方法定义里,少写 ...

  6. java 中的 hashcode

    在Java的Object类中有一个方法: public native int hashCode(); 根据这个方法的声明可知,该方法返回一个int类型的数值,并且是本地方法,因此在Object类中并没 ...

  7. [BZOJ5249][九省联考2018]IIIDX(线段树)

    5249: [2018多省省队联测]IIIDX Time Limit: 40 Sec  Memory Limit: 512 MBSubmit: 32  Solved: 17[Submit][Statu ...

  8. ML(5):KNN算法

    K近邻算法,即K-Nearest Neighbor algorithm,简称KNN算法,可以简单的理解为由那离自己最近的K个点来投票决定待分类数据归为哪一类.这个算法是机器学习里面一个比较经典的算法, ...

  9. JavaScript模块化-RequireJs实现AMD规范的简单例子

    AMD规范简介 AMD(异步模块定义),是实现JavaScript模块化规范之一,它采用异步方式加载模块,模块的加载不影响后面语句的运行.require.js和curl.js都是实现AMD规范的优秀加 ...

  10. TFS 2012如何切换用户

    TFS 2012如何切换用户 编写人:左丘文 2018-3-8 春节假期来后,准备干活的时候,才发现TFS账户登入的是另外一个账户.现在想切换为自己的账户时,发现Vs 2012中没找到可以登出的功能, ...