Lucky

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

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
 
Source
 
题意:集合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=;i<=t;i++)
{
scanf("%d",&n);
int flag1=;
int flag2=;
for(int j=;j<=n;j++)
{
scanf("%I64d",&a);
if(a==)
{
flag1=;
}
if(a==)
{
flag2=;
}
}
if(flag1==&&flag2==)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
} return ;
}

HDU 5665的更多相关文章

  1. HDU 5665 Lucky (水题)

    Lucky 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/G Description Chaos August likes to ...

  2. HDU 5665 Lucky

    看有没有0和1,都有的时候是YES,否则是NO #include<cstdio> #include<cstring> #include<cmath> #includ ...

  3. Hdu 5289-Assignment 贪心,ST表

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=5289 Assignment Time Limit: 4000/2000 MS (Java/Others) ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. 2.从print到自省

    print是一个函数   为什么print是一个函数呢?可以在交互式解释器下 输入: >>> type(print) 输出: <class 'builtin_function_ ...

  2. JavaScript实现判断图片是否加载完成的3种方法整理

    JavaScript实现判断图片是否加载完成的3种方法整理 有时候我们在前端开发工作中为了获取图片的信息,需要在图片加载完成后才可以正确的获取到图片的大小尺寸,并且执行相应的回调函数使图片产生某种显示 ...

  3. 文件 I/O字节流

    输入字节流: import java.io.*; public class test_main { public static void main(String[] args) { int n=-1; ...

  4. Matplotlib 基本图表的绘制

    图表类别:线形图.柱状图.密度图,以横纵坐标两个维度为主 同时可延展出多种其他图表样式 plt.plot(kind='line', ax=None, figsize=None, use_index=T ...

  5. BZ 600题祭

    不知不觉就600题了呢. 明天就要省选了.不要让这个数字定格在这里吧!

  6. 网站的robots.txt文件

    什么是robots.txt? robots.txt是一个纯文本文件,是爬虫抓取网站的时候要查看的第一个文件,一般位于网站的根目录下.robots.txt文件定义了爬虫在爬取该网站时存在的限制,哪些部分 ...

  7. Hibernate-ORM:13.Hibernate中的连接查询

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客将会解释Hibernate中的连接查询(各种join) 一,目录 1.内链接 1.1显式内连接(inn ...

  8. 剑指offer-二进制中1的个数11

    题目描述 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. class Solution: def NumberOf1(self, n): # write code here coun ...

  9. anaconda常用的命令

    常用操作命令: 一.环境操作 1.查看环境管理的全部命令帮助: conda env -h 2.查看当前系统下的环境: conda info -e 3.创建环境: conda create env_na ...

  10. Drools 7.4.1.Final参考手册(十四)集成Spring

    集成Spring Drools 6.0重要变更 Drools Spring集成经历了与Drools 6.0的变化完全一致的改造. 以下是一些主要的变化: T*推荐的Drools Spring的前缀已经 ...