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. oracle 11g 建库 建表 增 删 改 查 约束

    一.建库 1.(点击左上角带绿色+号的按钮) 2.(进入这个界面,passowrd为密码.填写完后点击下面一排的Test按钮进行测试,无异常就点击Connect) 二.建表 1-1. create t ...

  2. CountDownLatch的简单理解

    CountDownLatch的概念 CountDownLatch是一个同步工具类,用来协调多个线程之间的同步,或者说起到线程之间的通信(而不是用作互斥的作用). CountDownLatch能够使一个 ...

  3. PowerCollections

    Wintellect 的Power collections 库 BigList<String> str = new BigList<String>(); str.Add(&qu ...

  4. 在 php 7.3 中 switch 语句中使用 continue

    在 php 7.3 中 switch 语句中使用 continue 在 php 7.3 的 switch 中使用 continue 会出现警告.1 2 3 while ($foo) { switch ...

  5. php获取并删除数组的第一个和最后一个元素

    php中如何获取并删除数组的第一个或者最后一个元素?其实这两个过程都可以通过php自带的函数 array_pop 和 array_shift 来完成,下面就具体介绍一下如何来操作.(1)使用 arra ...

  6. 用Qstring给char[]数组赋值(转)

    tree_data.Desc  //Desc是char[80]类型的数据 Qstring newDescStr; strcpy(tree_data.Desc , newDescStr.toLocal8 ...

  7. Microsoft Dynamics CRM service 创建,更新等操作时,注意写抛出异常时,抛出SoapException异常

    具体如下: using System.Web.Services.Protocols; try{ crmService.Update(procurementPlanEntity);//更新操作}catc ...

  8. idea引入svn

    刚想在idea看一个svn的项目代码,结果发现导入项目后,idea在右下角弹出了Event Log窗口,里面的红色小字 Can't use Subversion command line client ...

  9. mysql视图 新手的问答

    ☺ζั͡ޓއއއ๓º♥双٩(•(365335093) 16:03:02 创建的视图能保存多长时间,保存在哪啊 上天&宠儿(961431958) 16:08:59 数据库 上天&宠儿(9 ...

  10. Linux内核深入研究之进程的线性地址空间-传统版

    引言: 了解Linux环境下,进程的地址空间划分,对于我们理解Linux应用程序有很大的帮助,否则会被New与Malloc之类的指针操作弄的晕头转向,本文基于Linux内核讲述了Linux/Unix线 ...