【题解】Cutting Game

本文深入探讨了SG函数的概念及其在公平组合游戏理论中的应用。通过具体实例CuttingGame,展示了如何使用SG函数判断游戏状态的胜负,并提供了一段C++代码实现。对于理解复杂游戏策略和算法设计具有一定的参考价值。

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

【题解】Cutting Game

vjudge

谈谈对\(sg\)函数的理解?

浅谈公平组合游戏IGC

//@winlere
#include<cstring>
#include<cstdio>
using namespace std;  typedef long long ll;
const int maxn=201;
int temp[maxn];
int sg[maxn][maxn],a,b;

int main(){
      for(register int n=2;n<=200;++n)
        for(register int m=2;m<=200;++m){
          memset(temp,0,sizeof temp);
          for(register int p=2;n-p>=2;++p)temp[sg[p][m]^sg[n-p][m]]=1;
          for(register int p=2;m-p>=2;++p)temp[sg[n][p]^sg[n][m-p]]=1;
          for(register int p=0;p<=200;++p)
            if(!temp[p]) {sg[n][m]=p;break;}
        }
      while(~scanf("%d %d",&a,&b)) sg[a][b]?puts("WIN"):puts("LOSE");
      return 0;
}

转载于:https://www.cnblogs.com/winlere/p/10848226.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值