hdu 5665 Lucky(简单题)(bestcoder#80 1000)

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.

    1n105,1T10,0ai109 .
 

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

Sample Input
   
   
   
   
1 1 2
 

Sample Output
   
   
   
   
NO
 

Source
BestCoder Round #80
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:   5674  5673  5672  5671  5670 
 

题目大意:

        给定n个数字,如果每个(数可以使用多次)可以求和组成所有自然数,输出YES,否则输出NO

解题思路:

        看有没有一,有1一定行,没1一定不行,另外没零一定不行!用这个没零的用例叉掉了TooDifficult 蛤蛤蛤。


#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#define ll long long
#define INF 0x3f3f3f3f
#define C(a) memset(a,0,sizeof a)
#define C_1(a) memset(a,-1,sizeof a)
#define C_i(a) memset(a,0x3f,sizeof a)
#define F(i,n) for(int i=0;i<n;i++)
#define F(n) for(int i=0;i<n;i++)
#define F_1(n) for(int i=n;i>0;i--)
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define SL(a) scanf("%I64d",&a)
#define SD(a) scanf("%lf",&a)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%I64d\n",a)
#define PD(a)printf("%lf\n",a)
#define rush() int t;scanf("%d",&t);while(t--)
using namespace std;
int main()
{
	rush()
	{
		int n,tem,flag0=0,flag1=0;
		S(n);
		F(n)
		{
			scanf("%d", &tem);
			if (tem == 1)flag1 = 1;
			if (tem == 0)flag0 = 1;
		}
		if(flag0&&flag1)printf("YES\n");//MDZZ大小写
		else printf("NO\n");
	}
}



你可能感兴趣的:(简单题,BestCoder)