zoukankan      html  css  js  c++  java
  • 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;
    }
     
  • 相关阅读:
    JAVA C 数据类型对应
    JAVA javah
    JAVA java
    JAVA javac
    JAVA jar命令(一)-jar打包class文件
    Unity 中调用Android的JAVA代码
    unity 打包Apk生成签名证书keystore
    SQL Server 备份还原
    C/C++ warning C4251: class ... 需要有 dll 接口由 class“..” 的客户端使用
    如何修复 WordPress 中的 HTTP 错误
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5399843.html
Copyright © 2011-2022 走看看