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 ...
随机推荐
- JQuery实现高级检索功能
https://blog.csdn.net/muziruoyi/article/details/44494465 < div id= "0" class ="row ...
- python 直接将list 整体转化-----------map()
假设有这样一个 results = ['1', '2', '3'] 转化为下面这个样子 results = [1, 2, 3] 我们可以使用map函数 在Python2中这样操作: results = ...
- ASP.NET MVC中如何以ajax的方式在View和Action中传递数据
前言:写这篇随笔的时候,在url上漏写了斜线,找了好久错误,整个人都很不好.#我是猪系列 背景:之前介绍过一篇如何构建 MVC&AJax&JSon示例,这一篇单独讲解如何在View和A ...
- log4j的格式化打印
log4j.properties的文件内容如下 log4j.rootLogger=INFO, stdoutlog4j.appender.stdout=org.apache.log4j.ConsoleA ...
- django admin model使用技巧
自定义记录返回值班 和 表名 class Guys(models.Model): first_name = models.CharField(max_length=30) last_name = mo ...
- 如何调试触发器-MSSQL (转帖)
调试触发器 //------------------------------------- 作者:四海为圈(原创) //------------------------------------- 1. ...
- 利用springMVC包装类上传多个文件
前端JSP页面代码片段: <!-- springMVC包装类上传文件 --><form name="uploadFiles" id="uploadFil ...
- WPF Demo4
<Window x:Class="Demo4.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/ ...
- phonegap 2.9 IOS Xcode 搭建环境
一:下载phoneGap2.9和安装Xcode5(目前最新版) 选择2.9是因为3.0以上坑爹版本编译神马的要在有网络情况. 二: 下载phonegap后解压到你的指定文件夹中,解压后找到create ...
- JAVA课程设计——多源教学数据管理系统
团队简介 团队名称: 419圣斗士 团队成员 姓名 成员介绍 任务分配 周炳辉(组长) 来自网络的一个大佬,穿女装很合适 poi与servlet 徐宏伟 网络中一个具有强大隐藏实力的大哥 css,部分 ...