zoukankan      html  css  js  c++  java
  • Codeforces 1383B GameGame(博弈)

    题意:长度为n的数组a,Va=Vb=0,先手选出一个a【i】xor Va,后手同理,,Va>Vb为胜利,给出a【】问必胜,必败还是平局。

    题解:https://codeforces.com/blog/entry/80562

    #include <bits/stdc++.h>
    #define IOS ios::sync_with_stdio(false);cin.tie(0)
    #define fre freopen("C:\in.txt", "r", stdin)
    #define _for(i,a,b) for(int i=a; i< b; i++)
    #define _rep(i,a,b) for(int i=a; i<=b; i++)
    #define lowbit(a) ((a)&-(a))
    #define inf 0x3f3f3f3f
    #define endl "
    "
    
    using namespace std;
    typedef long long ll;
    template <class T>
    void read(T &x)
    {
        char c; bool op=0;
        while(c=getchar(), c<'0'||c>'9') if(c=='-') op=1;
        x=c-'0';
        while(c=getchar(), c>='0'&&c<='9') x=x*10+c-'0';
        if(op) x=-x;
    }
    
    const int maxn=1e5+5;
    int T, n, a[maxn];
    
    int main()
    {
        //fre;
        read(T);
        while(T--)
        {
            read(n);
            int x=0, k=30;
            _rep(i, 1, n) read(a[i]), x^=a[i];
            if(!x){
                printf("DRAW
    "); continue;
            }
            while(!(x>>k&1)) k--;
            //printf("k=%d
    ", k);
            vector<int> f(2);
            _rep(i, 1, n) f[a[i]>>k&1]++;
            if(f[1]%4==3 && f[0]%2==0) printf("LOSE
    ");
            else printf("WIN
    ");
        }
        return 0;
    }
  • 相关阅读:
    IOTest-InputStream-OutputStream
    JSP
    java链表
    区块链
    MySQL常用命令
    jQuery
    javascript
    Nginx
    Linux
    Hive
  • 原文地址:https://www.cnblogs.com/Yokel062/p/13437270.html
Copyright © 2011-2022 走看看