Lucky

题目链接:

http://acm.hust.edu.cn/vjudge/contest/123316#problem/G

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.

.

Output

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

Sample Input

1

1

2

Sample Output

No

题意:

给出一个具有n个数字的集合;

定义lucky number:不能由集合中的数字相加得到的最小的数.

题解:

能否构成任意正数取决于是否含有1,有1则一定能,否则一定不能.

注意题目说的是非负整数,则还要考虑0; 只有当含有0的时候才能得到0.

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#define LL long long
#define eps 1e-8
#define maxn 1100
#define inf 0x3f3f3f3f
#define IN freopen("in.txt","r",stdin);
using namespace std; int n; int main(int argc, char const *argv[])
{
//IN; int t; scanf("%d", &t);
while(t--)
{
scanf("%d", &n); int flag = 0;
int flag2 = 0;
for(int i=1; i<=n; i++) {
int x; scanf("%d", &x);
if(x == 1) flag = 1;
if(x == 0) flag2 = 1;
} if(flag && flag2) printf("YES\n");
else printf("NO\n");
} return 0;
}

HDU 5665 Lucky (水题)的更多相关文章

  1. hdu 5210 delete 水题

    Delete Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...

  2. hdu 1251 (Trie水题)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  3. HDU 5703 Desert 水题 找规律

    已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...

  4. HDU 4493 Tutor 水题的收获。。

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...

  5. hdu 4802 GPA 水题

    GPA Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4802 Des ...

  6. hdu 4493 Tutor 水题

    Tutor Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...

  7. hdu 5495 LCS 水题

    LCS Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5495 Descr ...

  8. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  9. hdu 5734 Acperience 水题

    Acperience 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5734 Description Deep neural networks (DN ...

随机推荐

  1. NFC(4)响应NFC设备时启动activity的四重过滤机制

    响应NFC设备时启动activity的四重过滤机制 在一个NFC设备读取NFC标签或另一个NFC设备中的数据之前会在0.1秒之内建立NFC连接,然后数据会自动从被读取一端流向读取数据的一端(NFC设备 ...

  2. UserAccountInfo时间倒计时

    界面如下: 代码如下: using System;using System.Collections.Generic;using System.ComponentModel;using System.D ...

  3. 沉浸式学 Git

    沉浸式学 Git cover — contents — about 目录 设置 再谈设置 创建项目 检查状态 做更改 暂存更改 暂存与提交 提交更改 更改而非文件 历史 别名 获得旧版本 给版本打标签 ...

  4. UVa 11427 (期望 DP) Expect the Expected

    设d(i, j)表示前i局每局获胜的比例均不超过p,且前i局共获胜j局的概率. d(i, j) = d(i-1, j) * (1-p) + d(i-1, j-1) * p 则只玩一天就就不再玩的概率Q ...

  5. jquery datepicker-强大的日期控件

    在web开发中,总会遇到需要用户输入日期的情况.一般都是提供一个text类型的input供用户输入日期.然而,这种方式,开发人员必须对用户输入的日期进行验证,判断其合法性.除此之外,让用户输入日期也是 ...

  6. 为什么多数游戏服务端是用 C++ 来写

    早年开发游戏必须用C++,这没得说,2000-2004年,java还没有nio,其他动态语言不抗重负,只能C/C++能开发出完整可用的游戏服务端.直到2005年,韩国的游戏很多都还是纯C++写服务端, ...

  7. snv的绑定,检出,同步

    svn安装  http://www.android100.org/html/201511/15/196792.html svn绑定Studio 显示svn图标 效果图

  8. Tomcat 调优总结

    一. jvm参数调优 常见的生产环境tomcat启动脚本里常见如下的参数,我们依次来解释各个参数意义. export JAVA_OPTS="-server -Xms1400M -Xmx140 ...

  9. mysql违背了唯一约束

    执行一批数据,违背唯一约束时会中断,导致后面的数据写不进去. mysql有提供ignore关键字,使用insert ignore into .... 这样,当违背了唯一约束的时候~就会直接跳过,不会报 ...

  10. 组以逗号分隔的子串及跨平update join

    下列语句可以对组以逗号分隔的子串 set @device_cd_array += ', ' set @device_cd_array += @nodeid ,, '') update时要join表要先 ...