NIM博弈证明

博客给出结论:若a1 xor a2 xor a3... xor an ≠ 0则先手(R)赢,否则先手(R)输。并使用数学归纳法进行证明,先定义tem,再分别证明异或结果不为0时先手赢、为0时先手输,最终得出结论。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一:结论

a1 xor a2 xor a3 ... xor an≠0a_1 \ xor \ a_2 \ xor \ a_3 \ ... \ xor \ a_n \neq 0a1 xor a2 xor a3 ... xor an=0 则先手(RRR)赢
否则 先手(RRR)输


二:证明 (数学归纳法)

(1): 定义


tem=a1 xor a2 xor a3 ... xor antem = a_1 \ xor \ a_2 \ xor \ a_3 \ ... \ xor \ a_n tem=a1 xor a2 xor a3 ... xor an


(2):具体过程

①证明:若a1 xor a2 xor a3... xor an≠0a_1 \ xor \ a_2 \ xor \ a_3 ... \ xor \ a_n \neq 0a1 xor a2 xor a3... xor an=0 则当前先手(RRR)赢

首先,temtemtem 的二进制最高位必定在 ai(i∈[1,n])a_i (i \in [1, n])ai(i[1,n]) 的同一位上出现

满足条件的一个 a[i](i∈[1,n])a[i] (i \in [1, n])a[i](i[1,n]) 记作x,将 temtemtem 减去 temtemtem 二进制最高位转换成十进制的值记作 temptemptemp

易知:temp<=xtemp <= xtemp<=x

RRR 选择改变 xxx 时,我们将 xxx 减去 temptemptemp,这时 a1 xor a2 xor a3 ... xor an=0a_1 \ xor \ a_2 \ xor \ a_3 \ ... \ xor \ a_n = 0a1 xor a2 xor a3 ... xor an=0

即证: 若a1 xor a2 xor a3 ... xor an=0a_1 \ xor \ a_2 \ xor \ a_3 \ ... \ xor \ a_n = 0a1 xor a2 xor a3 ... xor an=0,则当前先手 (JJJ) 输。

转换成②



证明: 若a1 xor a2 xor a3 ... xor an=0a_1 \ xor \ a_2 \ xor \ a_3 \ ... \ xor \ a_n = 0a1 xor a2 xor a3 ... xor an=0,则当前先手 (JJJ) 输。

JJJ任意选择一堆拿走一堆牌

a1 xor a2 xor a3... xor an≠0a_1 \ xor \ a_2 \ xor \ a_3 ... \ xor \ a_n \neq 0a1 xor a2 xor a3... xor an=0

即证:若a1 xor a2 xor a3... xor an≠0a_1 \ xor \ a_2 \ xor \ a_3 ... \ xor \ a_n \neq 0a1 xor a2 xor a3... xor an=0 则当前先手(RRR)赢


结论:当最后都拿完时:a1 xor a2 xor a3 ... xor an=0a_1 \ xor \ a_2 \ xor \ a_3 \ ... \ xor \ a_n = 0a1 xor a2 xor a3 ... xor an=0,则上一次拿牌的人是先手 (RRR),所以 RRR

反之亦然,即证

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值