HDU 5665
2016-04-16 23:31
447 查看
Lucky
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 138 Accepted Submission(s): 96
[align=left]Problem Description[/align]
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".
[align=left]Input[/align]
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
.
[align=left]Output[/align]
Output“YES”or “NO”to every query.
[align=left]Sample Input[/align]
1
1
2
[align=left]Sample Output[/align]
NO
[align=left]Source[/align]
BestCoder Round #80
题意:集合S 中 有若干数 如果能够通过任意 组合(不限次数)加和得到所有 自然数 则输出“YES” 否则“NO”
题解:自然数包含0
判断可以发现 只有当S中存在 “0”与“1”时才会满足条件输出“YES”
#include<iostream> #include<cstring> #include<cstdio> #include<queue> #include<stack> #define ll __int64 #define pi acos(-1.0) using namespace std; int t; int n; ll a; int main() { scanf("%d",&t); for(int i=1;i<=t;i++) { scanf("%d",&n); int flag1=0; int flag2=0; for(int j=1;j<=n;j++) { scanf("%I64d",&a); if(a==1) { flag1=1; } if(a==0) { flag2=1; } } if(flag1==1&&flag2==1) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
相关文章推荐
- 使用 PDO 方式将 Session 保存到 MySQL 数据中
- 抛砖微信公众号应用开发
- mysql 下载及安装方法
- 【ATF】钱正平:大规模实时计算及其在阿里的应用与创新
- ubuntu下使用VNC连接树莓派raspberry
- ubuntu14.04配opencv2.4.11
- [LeetCode]70. Climbing Stairs
- 20160416
- Instruments检查视图卡顿和优化
- Eclipse中的常用快捷键
- POJ 3618 - Exploration 不一样的排序解决办法
- 树莓派之uboot
- 角色控制器之移动与飞行 [代码清单6-4]
- 类的静态变量访问
- 美国卫星撞月球 测试是否有水耗资7000多万美元
- JNDI定义tomcat资源
- ATF走进清华,阿里技术天团畅谈技术梦想
- 第3周 C语言及程序设计初步例程-42 将数据输出到文本文件
- [026]文本分类之SVM
- 解决vncserver看不到桌面的问题