zoukankan      html  css  js  c++  java
  • Being a Good Boy in Spring Festival HDU

    一年在外 父母时刻牵挂
    春节回家 你能做几天好孩子吗
    寒假里尝试做做下面的事情吧

    陪妈妈逛一次菜场
    悄悄给爸爸买个小礼物
    主动地 强烈地 要求洗一次碗
    某一天早起 给爸妈用心地做回早餐

    如果愿意 你还可以和爸妈说
    咱们玩个小游戏吧 ACM课上学的呢~

    下面是一个二人小游戏:桌子上有M堆扑克牌;每堆牌的数量分别为Ni(i=1…M);两人轮流进行;每走一步可以任意选择一堆并取走其中的任意张牌;桌子上的扑克全部取光,则游戏结束;最后一次取牌的人为胜者。
    现在我们不想研究到底先手为胜还是为负,我只想问大家:
    ——“先手的人如果想赢,第一步有几种选择呢?”

    Input输入数据包含多个测试用例,每个测试用例占2行,首先一行包含一个整数M(1<M<=100),表示扑克牌的堆数,紧接着一行包含M个整数Ni(1<=Ni<=1000000,i=1…M),分别表示M堆扑克的数量。M为0则表示输入数据的结束。
    Output如果先手的人能赢,请输出他第一步可行的方案数,否则请输出0,每个实例的输出占一行。
    Sample Input

    3
    5 7 9
    0

    Sample Output

    1
    #include <bits/stdc++.h>
    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<algorithm>
    #include<queue>
    #include<map>
    #include<set>
    #include<vector>
    #include<iomanip>
    using namespace std;
    typedef long long ll;
    const int inf = 0x3f3f3f3f;
    const int mod = 998244353;
    const double eps = 1e-8;
    const int mx = 3e6+1e3; //check the limits, dummy
    typedef pair<int, int> pa;
    const double PI = acos(-1);
    ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
    ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
    bool isprime(int n) { if (n <= 1)return 0; for (int i = 2; i * i <= n; i++)if (n % i == 0)return 0; return 1; }
    #define swa(a,b) a^=b^=a^=b
    #define re(i,a,b) for(int i=(a),_=(b);i<_;i++)
    #define rb(i,a,b) for(ll i=(a),_=(b);i>=_;i--)
    #define clr(a,b) memset(a, b, sizeof(a))
    #define lowbit(x) ((x)&(x-1))
    #define mkp make_pair
    //inline ll qpow(ll a, ll b) { return b ? ((b & 1) ? a * qpow(a * a % mod, b >> 1) % mod : qpow(a * a % mod, b >> 1)) % mod : 1; }
    //inline ll qpow(ll a, ll b, ll c) { return b ? ((b & 1) ? a * qpow(a * a % c, b >> 1) % c : qpow(a * a % c, b >> 1)) % c : 1; }
    void ca(int kase, int ans) { cout << "Case #" << kase << ": " << ans << endl; }
    void sc(int& x) { scanf("%d", &x); }void sc(int64_t& x) { scanf("%lld", &x); }void sc(double& x) { scanf("%lf", &x); }void sc(char& x) { scanf(" %c", &x); }void sc(char* x) { scanf("%s", x); }
    int n, m, t, k;
    int a[mx];
    int main()
    {
        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        while (cin >> n && n) {
            re(i, 0, n)cin >> a[i];
            int sum = 0, ans = 0;
            re(i, 0, n)sum ^= a[i];//求Nim-sum
            if (sum == 0)cout << 0 << endl;//开局P-position先手败
            else {//开局N-position先手胜
                re(i, 0, n)if ((sum ^ a[i]) <= a[i])ans++; 
                cout << ans << endl;
            }
        }
        return 0;
    }
  • 相关阅读:
    flex 居中并两端对齐
    搭建Docker环境---私有仓库registry搭建
    搭建Docker环境---常用命令
    搭建Docker环境---Docker安装(centos7)
    搭建Docker环境---Docker概述
    Shell脚本
    安装webstrom2019
    mysql主从配置
    MySql5.7安装(centos 7)
    MySQL父子节点查询
  • 原文地址:https://www.cnblogs.com/xxxsans/p/12862549.html
Copyright © 2011-2022 走看看