hdoj 5665 Lucky 【水题】

题目链接:hdoj 5665 Lucky

Lucky

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 465 Accepted Submission(s): 282

Problem Description
Chaos August likes to study the lucky numbers.

For a set of numbers S,we set the minimum non-negative integer,which can't be gotten by adding the number in S,as the lucky number.Of course,each number can be used many times.

Now, given a set of number S, you should answer whether S has a lucky number."NO" should be outputted only when it does have a lucky number.Otherwise,output "YES".

Input
The first line is a number T,which is case number.

In each case,the first line is a number n,which is the size of the number set.

Next are n numbers,means the number in the number set.

1≤n≤105,1≤T≤10,0≤ai≤109.

Output
Output“YES”or “NO”to every query.

Sample Input
1
1
2

Sample Output
NO

题意:给定一个集合,你可以使用任意一个元素多次。问你该集合能否得到所有的非负数。

特判0和1即可。

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <cmath>
#include <queue>
#include <stack>
#define ll o<<1
#define rr o<<1|1
#define CLR(a, b) memset(a, (b), sizeof(a))
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
int a[MAXN];
int main()
{
    int t; scanf("%d", &t);
    while(t--) {
        int n; scanf("%d", &n);
        bool flag = false;
        bool zero = false;
        for(int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
            if(a[i] == 1) {
                flag = true;
            }
            if(a[i] == 0) {
                zero = true;
            }
        }
        printf(flag&&zero ? "YES\n" : "NO\n");
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值