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
 

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");
	}
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值