CodeForces - 471A MUH and Sticks

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiang_6/article/details/89039738

思路:

若是可以组成的熊或者大象,那肯定有4个数是相同的,减去这几个数

剩下的两个数相同就是大象,否则胸

#include<bits/stdc++.h>
 
using namespace std;
const int maxn = 10 + 7;
 
int cnt[maxn] = {0};
int main() {
    int id = 0;
    for(int i = 0; i < 6; ++i) {
        int a;
        scanf("%d", &a);
        cnt[a]++;
        if(cnt[a] >= 4) id = a;
    }
    if(!id) return 0*puts("Alien");
    cnt[id] -= 4;
    int ans = 0;
    for(int i = 1; i <= 9; ++i)
        if(cnt[i]) ans++;
    if(ans == 1) puts("Elephant");
    else puts("Bear");
 
    return 0;
}

猜你喜欢

转载自blog.csdn.net/xiang_6/article/details/89039738