• hdu-5665 Lucky(水题)


    题目链接:

    Lucky

    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 <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <queue>
    #include <cmath>
    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
    ");
            else printf("NO
    ");
        }
    
        return 0;
    }
     
  • 相关阅读:
    [纯C#实现]基于BP神经网络的中文手写识别算法
    【转载】Jedis对管道、事务以及Watch的操作详细解析
    redis 缓存用户账单策略
    redis 通配符 批量删除key
    explain分析sql效率
    mysql 常用命令大全
    【转载】实战mysql分区(PARTITION)
    mysql表名忽略大小写配置
    【转】微服务架构的分布式事务解决方案
    【转载】Mysql中的Btree与Hash索引比较
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5399843.html
Copyright © 2020-2023  润新知