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.
Input
The first line is a number T,which is case number.
Output
Output“YES”or “NO”to every query.
Sample Input
1
1
2
Sample Output
NO
题意:给定一个集合,你可以使用任意一个元素多次。问你该集合能否得到所有的非负数。
特判0和1即可。
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; }
相关文章推荐
- Shell图形界面dialog应用详解
- 文章标题
- Centos6.7源码安装 redis
- Matlab函数备忘2
- <meta name="viewport" >
- Android开发之解决APP启动白屏或者黑屏闪现的问题
- 【笔记本】第二阶段工作完成
- eclipse svn插件卸载 重新安装 Subclipse卸载安装 The project was not built since its build path is incomplete This client is too old to work with the working copy at
- 数据结构与算法分析java——线性表3 (LinkedList)
- opencv安装和使用过程中遇到的问题
- 算法导论 第22章 22.2-8
- Linux 命令大全
- Mybatis之XML配置文件解析
- [改善Java代码] 避免instanceof非预期结果
- am335x backlight
- 实例讲解Android中ContentProvider组件的使用方法
- CSS <hr>标签在float布局中Firefox和Chrome的差异
- CSS <hr>标签在float布局中Firefox和Chrome的差异
- hadoop-common源码分析之-Configuration
- 小米闪屏页闪过一道白色页面的问题解决办法