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 ...
随机推荐
- Open-sourcing sso, the way we secure services at BuzzFeed
文章来源: https://tech.buzzfeed.com/unleashing-the-a6a1a5da39d6 说明: 设计有好多地方值得借鉴,粘贴过来的排版不好 Today we are o ...
- GridView实现数据编辑和删除
<asp:GridView ID="gv_Emplogin" runat="server" AutoGenerateColumns="False ...
- 模板引擎之jade 学习
jade 模板引擎在node express 开发中有较多的使用,首先我们看一个简单的使用jade 生成的html 页面的标签代码: doctype html html(lang="en&q ...
- div+css 怎么让一个小div在另一个大div里面 垂直居中
div+css 怎么让一个小div在另一个大div里面 垂直居中 方法1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 .parent { width:800 ...
- Centos下LNMP安装
安装nginx [root@xuegod64 ~]# yum install -y gcc gcc-c++ autoconf automake zlib zlib-devel openssl open ...
- SimpleSocket
项目地址 : https://github.com/kelin-xycs/SimpleSocket SimpleSocket 一个 用 C# 调用 Win Socket 2 的 程序 , 对 Win ...
- 什么是Base64算法?什么情况下用Base64算法?
base64 编码的本质:将 8bit 二进制数转化为 6bit 的可打印字符. Base64编码用于需要将二进制数据转为文本数据进行储存和传输的场景. Javascript内部的字符串,都以utf- ...
- linux ssh公钥免密码登录
ssh 无密码登录要使用公钥与私钥.linux下可以用用ssh-keygen生成公钥/私钥对,下面我以CentOS为例. 一.SSH公钥登录原理 在平时工作中我们经常要远程登录服务器,这就要用到SSH ...
- oracle schema 白话文详解
概述: (一)什么Oracle叫用户(user): A user is a name defined in the database that can connect to and access ob ...
- ES(1): Creat linux VM on Azure
本章记录在ES集群之前的环境准备工作,主要包含的内容如下: 目录: 创建linux虚拟机 启用root用户 创建linux虚拟机 首先创建一个云服务 按向导创建云服务名称,如下 创建虚拟机, 第二步: ...