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;
    }
     
  • 相关阅读:
    Oracle9使用oradata恢复数据库
    我该怎么安排下属的工作项目经理如何分配任务
    如果说中国的程序员技术偏低,原因可能在这里
    项目经理问:为什么总是只有我在加班 – 挂包袱现象
    【转】面试真经
    [JAVA]PING和TELNET用法介绍
    Hello World 你懂的
    线程间操作控件
    获取客户端相关信息
    winfrom 特效 [转载]
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5399843.html
Copyright © 2011-2022 走看看