尼姆游戏c语言编程,[LeetCode]-292. Nim Game(Easy)(C + 尼姆游戏)

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.

Both of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.

For example, if there are 4 stones in the heap, then you will never win the game: no matter 1, 2, or 3 stones you remove, the last stone will always be removed by your friend.

Hint:

If there are 5 stones in the heap, could you figure out a way to remove the stones such that you will always be the winner?

Credits: Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.

Subscribe to see which companies asked this question

Show Tags

Show Similar Problems

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
知识总结 1 一、整除的性质: 3 二、数的整除特征 3 三、奇偶的性质 4 四、模p运算 4 五、同余的性质 4 六、余数检验 5 七、素数 6 八、素数的检验 7 九、最大公约数 8 十、算术基本定理 9 十一、一些数论的定理 9 十二、二次剩余 9 十三、梅森数 10 十四、完全数 11 十五、费马数 12 十六、完全平方数 12 十七、水仙花数 13 十八、西西弗斯数 13 十九、高度合成数 13 二十、斐波那契数 13 二十一、亲和数 14 二十二、欧拉数 14 二十三、欧拉的其他公式 15 二十四、欧拉方程 15 二十五、勾股数的特点 16 二十六、勾股数系的系和组 17 二十七、勾股数系的性质 17 二十八、二元一次不定方程 18 二十九、中国同余式 18 三十、数列 18 三十一、常识 19 三十二、幻方 19 三十三、克拉茨命题 20 三十三、用牛顿叠代法求高精度倒数 21 三十四、用二分法求解n! 21 三十五、高精度求乘幂 21 三十六、高精度求实数乘幂 22 三十七、高精度求对数 23 三十八、乘法的快速傅立叶转换 23 三十九、FFT 乘法 24 四十、高精度求开方 25 四十一、对原函数进行高精度求解 26 四十二、巴什博奕(Bash Game): 27 四十三、威佐夫博奕(Wythoff Game): 27 四十四、尼姆博奕(Nimm Game): 28 四十五、取火柴游戏 29 四十六、取硬币游戏 30 四十七、分金币 30 四十八、三人行游戏 31 四十九、3个教士和3个土人 31 五十、分酒问题 32 五十一、砝码 33 五十二、杨辉三角 34 五十三、图论的一些定理: 37 五十四、二部图 38 五十五、排列组合问题 39 五十六、计数问题 39 五十七、微积分公式 41 五十八、三角函数公式 43 五十九、空间解析几何和向量代数: 44 六十、多元微积分 44 六十一、多元函数微分法及应用 47 六十二、微分法在几何上的应用: 48 六十三、级数: 49 六十四、微分方程: 52 六十五、数学常用公式 53 六十六、二维图形的周长与面积公式 56 六十七、程序 58

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值