zoukankan      html  css  js  c++  java
  • CodeForces

    Alice and Bob are playing a game with nn piles of stones. It is guaranteed that nn is an even number. The ii-th pile has aiai stones.

    Alice and Bob will play a game alternating turns with Alice going first.

    On a player's turn, they must choose exactly n2n2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n2n2 nonempty piles).

    Given the starting configuration, determine who will win the game.

    Input

    The first line contains one integer nn (2n502≤n≤50) — the number of piles. It is guaranteed that nn is an even number.

    The second line contains nn integers a1,a2,,ana1,a2,…,an (1ai501≤ai≤50) — the number of stones in the piles.

    Output

    Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes).

    Examples

    Input
    2
    8 8
    
    Output
    Bob
    
    Input
    4
    3 1 4 1
    
    Output
    Alice

    题意:
    给偶数(n)堆石子,每一步必须取n/2堆石子中的任意多个,当场上不足n/2堆石子时,当前玩家失败,问谁是最后的获胜者。
    思路:
    如果有任何一堆石子已经被拿空,那么只需要直接取空n/2堆石子,便可以获胜。
    所以作为后手,如果能维护石子数量最小的堆数量大于N,便可以取胜,因为在这种情况下,石子数越来越少,先手总会拿空一堆。

    #include<iostream>
    #include<algorithm>
    #include<vector>
    #include<stack>
    #include<queue>
    #include<map>
    #include<set>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<ctime>
    #define fuck(x) cout<<#x<<" = "<<x<<endl;
    #define debug(a,i) cout<<#a<<"["<<i<<"] = "<<a[i]<<endl;
    #define ls (t<<1)
    #define rs ((t<<1)+1)
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    const int maxn = 100086;
    const int maxm = 100086;
    const int inf = 2.1e9;
    const ll Inf = 999999999999999999;
    const int mod = 1000000007;
    const double eps = 1e-6;
    const double pi = acos(-1);
    int num[maxn];
    int main()
    {
    //    ios::sync_with_stdio(false);
    //    freopen("in.txt","r",stdin);
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&num[i]);
        }
        sort(num+1,num+1+n);
        if(num[n/2+1]!=num[1]){printf("Alice
    ");}
        else printf("Bob
    ");
        return 0;
    }
    View Code
  • 相关阅读:
    把旧系统迁移到.Net Core 2.0 日记 (18) --JWT 认证(Json Web Token)
    把旧系统迁移到.Net Core 2.0 日记 (17) --多租户和SoftDelete
    swagger访问api, TypeError: Failed to fetch
    nop 4.1 Widget 探究- 视图组件
    Nop 4.1版本已经迁移到.net core2.1版本
    link标签和css引入方式
    script标签
    MIME 类型
    bae64编码
    chrome调试技巧和插件介绍
  • 原文地址:https://www.cnblogs.com/ZGQblogs/p/10840951.html
Copyright © 2011-2022 走看看