【博弈论】洛谷劝退篇

版权声明:转载标注来源喔~ https://blog.csdn.net/iroy33/article/details/89817861

被洛谷博弈论劝退了,连着两天开了两道题,题解都没有看懂,两天晚上没了,挂一下

P2575 高手过招

这是一道阶梯尼姆

参考博客 等我重拾耐心我就帮博主大大写注释

P2148 E&D

暴力打表,完全看不出来sg(a,b)的值为(a-1)|(b-1)结果0出现的二进制位的最低位诶。。。

优秀的证明!

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long LL;

const int N=11000;
int sg[110][110];
bool vis[N];
void pre()
{
    sg[1][1]=0;
    int a,b,c;  //c<b<a
    for(int a=2;a<100;++a)
    {
        for(int b=1;b<=a;++b)
        {
            memset(vis,0,sizeof(vis));
            for(int c=1;c<a;++c)           //从a中取出c个 将a分成两个不为0的堆
            {
               vis[sg[max(c,a-c)][min(c,a-c)]]=1;
            }
            for(int c=1;c<b;++c)
            {
                vis[sg[max(c,b-c)][min(c,b-c)]]=1;
            }
            for(int i=0;;++i)
            {
                if(!vis[i])
                {
                    sg[a][b]=i;
                    break;
                }

            }

        }
    }
}
int main()
{
    pre();
    //cout<<"?"<<endl;
    cout<<endl;
    for(int a=1;a<=50;++a)
    {
        cout<<a<<' ';
        for(int b=1;b<=a;++b)
           cout<<sg[a][b]<<' ';
        cout<<endl;
    }

}
扫描二维码关注公众号,回复: 6187079 查看本文章

猜你喜欢

转载自blog.csdn.net/iroy33/article/details/89817861