博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu-5665 Lucky(水题)
阅读量:4654 次
发布时间:2019-06-09

本文共 1452 字,大约阅读时间需要 4 分钟。

题目链接:

Time Limit: 2000/1000 MS (Java/Others)  

  Memory Limit: 65536/65536 K (Java/Others)

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.
    1n10^5,1T10,0ai10^9.
 

 

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

 

Sample Input
 
1
1
2
 

 

Sample Output
 
NO
 
题意:
 
问给的这个集合,能否用这个集合的数相加得到任意的自然数,每个数可以用无数遍;
 
思路:
 
只要有0和1就可以得到所有的自然数;
 
AC代码:
 
#include 
#include
#include
#include
#include
#include
using namespace std;typedef long long ll;const ll mod=1e9+7;const int N=1e5+10;int n,a[N];int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d",&n); int flag1=0,flag2=0; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); if(a[i]==1)flag1=1; if(a[i]==0)flag2=1; } if(flag1&&flag2)printf("YES\n"); else printf("NO\n"); } return 0;}

 

 

转载于:https://www.cnblogs.com/zhangchengc919/p/5399843.html

你可能感兴趣的文章
Dao层设计
查看>>
css各种姿势的水平居中
查看>>
MYSQL 测试常用语句使用技巧
查看>>
基础细节知识
查看>>
树状数组求区间最大值
查看>>
从面试官角度来告诉大家,哪些人能面试成功
查看>>
以我的亲身经历为例,告诉大家写简历和面试的技巧(面向高级开发和架构师)...
查看>>
一个简单的PHP网站结构
查看>>
Redis 学习之简介及安装
查看>>
jsp简单的学习
查看>>
[LeetCode][JavaScript]Number of 1 Bits
查看>>
[LeetCode][JavaScript]Plus One
查看>>
C语言-06复杂数据类型-01数组
查看>>
同余方程 2012年NOIP全国联赛提高组
查看>>
vue 图片预览插件
查看>>
深入解析:分布式系统的事务处理经典问题及模型
查看>>
python的2种字符串格式化输出
查看>>
Netsharp快速入门(之14) 销售管理(报表A 热销滞销品统计)
查看>>
配置 SQL Server Email 发送以及 Job 的 Notification通知功能
查看>>
线上应用bug跟踪查找-友盟统计
查看>>