zoukankan      html  css  js  c++  java
  • Be the Winner HDU

    就是   好几堆苹果  每堆苹果排成一条线  可以任意从每堆拿苹果   如果一堆苹果里拿了之后  则有两种情况  

    1、从不是边缘拿   拿完这一堆变成两堆

    2、从边缘拿   拿完还是一堆

    题目还要求 谁拿最后一堆 谁输。。这种类型的分析看这个吧   https://www.cnblogs.com/WTSRUVF/p/9339499.html

    看着其他人直接异或。。我还是练一下sg吧。。。。

    #include <iostream>
    #include <cstdio>
    #include <sstream>
    #include <cstring>
    #include <map>
    #include <set>
    #include <vector>
    #include <stack>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #define MOD 2018
    #define LL long long
    #define ULL unsigned long long
    #define Pair pair<int, int>
    #define mem(a, b) memset(a, b, sizeof(a))
    #define _  ios_base::sync_with_stdio(0),cin.tie(0)
    //freopen("1.txt", "r", stdin);
    using namespace std;
    const int maxn = 10010, INF = 0x7fffffff;
    int sg[maxn];
    int w;
    void mex()
    {
        mem(sg, 0);
        bool vis[maxn];
        for(int i=1; i<=w; i++)
        {
            mem(vis, 0);
            for(int j=1; j<=i; j++)
            {
                vis[sg[i-j]] = 1;
                int tot = i-j;
                for(int k=1; k<tot; k++)
                    vis[sg[k]^sg[tot-k]] = 1;
            }
            for(int j=0; ; j++)
                if(!vis[j])
                {
                    sg[i] = j;
                    break;
                }
        }
    }
    
    int main()
    {
        int n;
        while(cin>> n)
        {
            int cnt = 0, res = 0;
            for(int i=0; i<n; i++)
            {
                cin>> w;
                mex();
                res ^= sg[w];
                if(w == 1) cnt++;
            }
            if(res && cnt != n)
                cout<< "Yes" <<endl;
            else if(!res && cnt == n)
                cout<< "Yes" <<endl;
            else
                cout<< "No" <<endl;
    
        }
    
        return 0;
    }
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    常见限流算法
    spring aop 事物
    Java序列化和反序列化为什么要实现Serializable接口
    java类在何时被加载?
    mysql 排序 是怎么工作的?
    程序员转正述职报告
    .NET中使用Channel<T>
    .NET-服务承载系统(Hosting)(支持Cron表达式)
    JObject拼接Json字符串
    NET5 使用FTP发布
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9339523.html
Copyright © 2011-2022 走看看