您的位置:首页 > 其它

hdoj 5665 Lucky 【水题】

2016-04-21 16:07 417 查看
题目链接: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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: