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. 使用 GIT 获得Linux Kernel的代码并查看,追踪历史记录

    Linux kernel  的官方 GIT地址是: http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git 可以从这个地 ...

  2. ubuntu下android源码下载

    步骤一: 首先保证你的ubuntu系统电脑可以顺利游览google,我们是将etc下 hosts替换掉,推荐hosts: http://laod.cn/hosts/2015-google...host ...

  3. [Codeforces673A]Bear and Game(水题,思路)

    题目链接:http://codeforces.com/contest/673/problem/A 题意:一个人看一个90分钟的节目,然后告诉你一些有趣的时刻.这个人假如在15分钟内还没有看到有趣的时刻 ...

  4. hdu 2372 El Dorado (dp)

    题目链接 题意:给n个数字, 求有k个数字的上升子序列有多少种. 思路:d[i][j]表示 以第i个元素为 子序列的最后一个元素,长度为j的子序列 有多少种. 比赛的时候 光想着用组合数做了..... ...

  5. overload和override

    Overload是重载的意思,Override是覆盖的意思,也就是重写. 重载Overload表示同一个类中可以有多个名称相同的方法,但这些方法的参数列表各不相同(即参数个数或类型不同). 重写Ove ...

  6. bzoj1797: [Ahoi2009]Mincut 最小割

    最大流+tarjan.然后因为原来那样写如果图不连通的话就会出错,WA了很久. jcvb: 在残余网络上跑tarjan求出所有SCC,记id[u]为点u所在SCC的编号.显然有id[s]!=id[t] ...

  7. Web Api 中使用 PCM TO WAV 的语音操作

    /// <summary> /// 语音[文件.上传.解码.保存(WAV)] /// </summary> [DeveloperEx("Liwei:秘书语音需求单&q ...

  8. NSIS 2.0界面快速入门

    NSIS 2.0 版本支持定制的用户界面.所谓的 Modern UI(下称 MUI) 就是一种模仿最新的 Windows 界面风格的界面系统.MUI 改变了 NSIS 脚本的编写习惯,它使用 NSIS ...

  9. 【COCOS2DX-LUA 脚本开发之十二】Hybrid模式-利用AssetsManager实现在线更新脚本文件lua、js、图片等资源(免去平台审核周期)

    本站文章均为李华明Himi原创,转载务必在明显处注明:(作者新浪微博:@李华明Himi) 转载自[黑米GameDev街区] 原文链接: http://www.himigame.com/iphone-c ...

  10. acdream 1408 "Money, Money, Money" (水)

    题意:给出一个自然数x,要求找两个自然数a和b,任意多个a和b的组合都不能等于x,且要可以组合成大于x的任何自然数.如果找不到就输出两个0.(输出任意一个满足条件的答案) 思路:x=偶数时,无法构成, ...