leetcode292
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的更多相关文章
- LeetCode292:Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, eac ...
- [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 ...
- LeetCode 292
Nim Game You are playing the following Nim Game with your friend: There is a heap of stones on the t ...
随机推荐
- Assert随笔
☆ Assert.notNull(haha, "未找到需要导入的计划1");//haha必须不能为null,if为null则抛出message的异常: Assert.hasText ...
- freemarker逻辑判断写法#if
<li class="<#if (position.flag)! =='haha1'>hide<#else >show</#if>"> ...
- smarty学习——编写扩展
在进行了以上的开发环境的配置之后就是,进行进一步的学习,为了开发的方便我们一般会使用oop的编程思想,进行方便的处理 如下: 1.smartyUser 的创建 <?php require_onc ...
- web.xml中context-param详解
<context-param> <param-name>contextConfigLocation</param-name> <param-value> ...
- thrift 知识点
mac下,thrift 安装 mac下,最简单安装thrift的方法:使用brew安装 brew update brew install thrift 验证安装成功:thrift --help 安装出 ...
- java 中一些需要注意的知识点
java数组的length属性是容量,而不是数组真实元素的个数: 多线程中的interrupt()方法并不会终止处于"运行状态"的线程,它只是将线程的中断标记设为true. juc ...
- 【Reporting Services 报表开发】— 如何设置报表分页列标题每一页都显示
一.打开已经开发好的报表ReportTest,选择列组下的高级模式—>选择行组的静态(会关联列标题订单编号),修改下面的属性: 1.Hidden:False 2.FixedData:True 3 ...
- Win10 UEFI +Ghost +intel快速启动 新法完美安装
http://tieba.baidu.com/p/4767004289?qq-pf-to=pcqq.c2c Win10 如果主板不用Bios 而用UEFI引导启动,速度快,界面好.现在一般都用win1 ...
- g++编译后中文显示乱码解决方案
环境:Windows 10 专业版 GCC版本:5.3.0 测试代码: #include <iostream> using namespace std; int main(int argc ...
- java操作Excel之POI(3)
一.字体处理 /** * 字体处理 */ public static void main(String[] args) throws Exception { Workbook wb = new HSS ...