阅读367 返回首页    go 阿里云 go 技术社区[云栖]


poj 2960,hdu 1536 S-NIM 博弈

    同样的题目,又不会写了,还是没有完全理解博弈的内涵,又看了遍论文。

    明天一定要搞懂

    目前最新的想法是每个sg函数值代表的是到达必败态的方法,如果2个必胜方法一样,那么为输,否则为胜。明天再好好看看


/*
author:jxy
lang:C/C++
university:China,Xidian University
**If you need to reprint,please indicate the source**
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int s[101];
int k;
int sg[10005];
int get_sg(int x)
{
    if(~sg[x])return sg[x];
    int vis[101],i;
    memset(vis,0,sizeof(vis));
    for(i=0;i<k;i++)
    {
        if(s[i]>x)break;
        vis[get_sg(x-s[i])]=1;
    }
    for(i=0;vis[i];i++);
    return sg[x]=i;
}
int main()
{
    int i;
    while(~scanf("%d",&k)&&k)
    {
        memset(sg,-1,sizeof(sg));
        sg[0]=0;
        for(i=0;i<k;i++) scanf("%d",&s[i]);
        sort(s,s+k);
        int n,T,ans;
        scanf("%d",&T);
        while(T--)
        {
            ans=0;
            scanf("%d",&n);
            while(n--)
            {
                scanf("%d",&i);
                ans^=get_sg(i);
            }
            putchar(ans?'W':'L');
        }
        puts("");
    }
}


最后更新:2017-04-03 16:49:07

  上一篇:go Struts2中的&lt;s:action&gt;标签
  下一篇:go WebService报错javax.xml.ws.soap.SOAPFaultException: javax.xml.ws.WebFault.messageName()