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. POJ2182 Lost Cows

    题意 Language:Default Lost Cows Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13448 Accep ...

  2. WIFI_仿手机写wifi应用程序_WDS

    2-1.1_15节_使用WIFI网卡6_仿手机写wifi操作程序============================== 1. 仿手机写一个WIFI操作程序,作为STA,有这几个功能:a. 自动扫 ...

  3. hasura graphql-engine v1.0.0-alpha25 的几个方便功能

    hasura graphql-engine 是一个很不错的graphql 引擎,但是我们的数据模型经常可能会有变动, 但是以前的版本对于这些的处理,官方的方式是删除元数据,重启server,都不是很好 ...

  4. java中Thread类分析

    创建线程的方式有三种,一是创建Thread实例,二是实现Runnable接口,三是实现Callable接口,Runnable接口和Callable接口的区别是一个无返回值,一个有返回值:不管是Runn ...

  5. POJ2392 Space Elevator

    题目:http://poj.org/problem?id=2392 一定要先按高度限制由小到大排序! 不然就相当于指定了一个累加的顺序,在顺序中是不能做到“只放后面的不放前面的”这一点的! 数组是四十 ...

  6. springcould

     [Spring For All 社区周报] 「社区活动」(送书哦)Spring For All 第 1 期高手 QA 环节 — Spring Cloud 微服务实战http://spring4all ...

  7. Django 博客项目02 Form验证+ 上传头像(预览)+Ajax用户注册

    头像预览 $("#avatar_file").change(function(){ // 获取上传的文件对象 var file=$(this)[0].files[0]; // 读取 ...

  8. 【Oracle学习笔记-5--】集合操作之union,intersect和minus操作

    --union并操作 select e.employee_id,e.last_name from hr.employees e where e.last_name like 'C%' union se ...

  9. VMware NAT模式下设置网络

    一.虚拟机NAT模式原理 NAT模式在VMware下又称VMnet8.在这种模式下,宿主机有两块网卡,一块是真实的物理网卡(即NAT device),连接Network:一块是 VMware Netw ...

  10. python给字典排序

    应用场景: 统计一篇文章中单词的出现频率,然后进行排序 利用sorted函数,返回一个已经排序好的list,但不改变原来的数据结构 In [1]: dt = {'a':3,'b':2,'c':1} I ...