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 ...
随机推荐
- 《DSP using MATLAB》Problem 4.15
只会做前两个, 代码: %% ---------------------------------------------------------------------------- %% Outpu ...
- 定时器setTimeout()的传参方法
更具体的代码:http://www.cnblogs.com/3body/p/5416830.html // 由于setTimeout()的延迟执行特性,所以在执行的函数中直接使用外部函数的变量是无法获 ...
- cacheAsBitmap位图缓存
使用cacheAsBitmap将缓存显示对象的内部位图表示形式. 此缓存可以提高包含复杂矢量内容的显示对象的性能.此方法适合运用于较多的图片或文字移动,不过也不能太随意乱用,有利必有弊,使用cache ...
- Java中File常用的方法汇总
创建:createNewFile()在指定位置创建一个空文件,成功就返回true,如果已存在就不创建,然后返回false.mkdir() 在指定位置创建一个单级文件夹.mkdirs() 在指定位置创建 ...
- 在ubuntu中安装luci解决iwinfo.h No such file or directory问题
问题: src/luci-bwc.c:35:20: fatal error: iwinfo.h: No such file or directorycompilation terminated.mak ...
- Windows 客户端时间更新脚本NTP
Windows XP 客户端时间更新脚本NTP ::Windows XP 客户端时间更新脚本NTP reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsof ...
- unbuntu 安装及服务器配置
关于分区: 挂载点 装置 说明 / /dev/hda1 15G /home /dev/hda2 最大的剩余空间 /boot /dev/hda3 200MB左右 swap /dev/hda5 大约内存大 ...
- document.write覆盖问题
1.不会覆盖页面: 如果仅仅是一句js语句:document.writeln('<span id=\'span1\'>嗯,你好</span>'); ps:\'是转义字符,代表' ...
- TMOD
1. • tag/itemlist {{Syntax Error}} Debug info: Unexpected token else Waiting... Debug info: node D:/ ...
- 如何缓解DDOS攻击
1.减少攻击面 (a) reduce the number of necessary Internet entry points,(b) eliminate non-critical Internet ...