• 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;
    }
     
  • 相关阅读:
    Attacklab markup
    Bomblab markup
    Diary & Solution Set 多校度假
    Solution 「CF 590E」Birthday
    MySQL 避坑宝典 来自小米的开源工具
    Hive SQL语法Explode 和 Lateral View
    「Ynoi2006」rsrams
    「Gym103069C」Random Shuffle
    「UOJ498」新年的追逐战
    「Nowhere」Helesta
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5399843.html
Copyright © 2020-2023  润新知