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 ...
随机推荐
- hiho1622 有趣的子区间(YY)
题目链接:http://hihocoder.com/problemset/problem/1622?sid=1230113 #1622 : 有趣的子区间 时间限制:10000ms 单点时限:1000m ...
- Linux regulator系统
1. 概念:Regulator : 电源芯片, 比如电压转换芯片Consumer : 消费者,使用电源的部件, Regulator是给Consumer供电的machine : 单板,上面焊接有Regu ...
- linux的性能优化
转一位大神的笔记. linux的性能优化: 1.CPU,MEM 2.DISK--RAID 3.网络相关的外设,网卡 linux系统性能分析: top:linux系统的负载,CPU,MEM,SWAP,占 ...
- jp@gc - Stepping Thread Group 字段说明
1. 安装好插件 参考文档“扩展Jmeter插件获取更多监听器” 2. 添加线程组 右键测试计划->添加->Threads(Users)->jp@gc - Stepping ...
- JSOI2008——星球大战
题目:https://www.luogu.org/problemnew/show/1197 并查集. 难点是若依次去掉点在求连通块个数,时间太长. 精妙的思维:先全部读入,再逆向求连通块个数——增加点 ...
- Apache Shiro在web开发安全框架中的应用
前阶段就hadoop的分享了一些内容,希望对新手入门的朋友有点帮助吧!对于hadoop新手入门的,还是比较推荐大快搜索的DKHadoop发行版,三节点标准版还是值得拥有的(三节点的标准版是可以免费下载 ...
- 织梦ask标签的调用
EDE 问答首页调用标签 标签名称: ask 功能说明:问答调用标签 适用范围:全局使用 基本语法: {dede:ask row='6' qtype='new' tid='0' titlelen='2 ...
- Django ORM基本的单表增删改查
创建表 步骤: 1.app下models.py里创建类(继承models.Model) from django.db import models class UserInfo(models.Model ...
- WPF Demo3
<Window x:Class="Demo3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/ ...
- var_dump() 查看字符的类型 方法