HDU 5665 Lucky

看有没有0和1,都有的时候是YES,否则是NO

#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;

int flag1, flag2;

int main()
{
    int T,n;
    scanf("%d", &T);
    while (T--)
    {
        flag1 = flag2 = 0;
        scanf("%d", &n);
        while (n--)
        {
            int x; scanf("%d", &x);
            if (x == 0) flag1 = 1;
            if (x == 1) flag2 = 1;
        }
        if (flag1&&flag2) printf("YES
");
        else printf("NO
");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zufezzt/p/5400256.html