[HDU] [5665] Lucky

Problem Description

Loading...

Problem Analysis

Given several numbers
ask whether sums of them can form any natural number
The problem states:

  1. each number can be used infinitely many times
  2. you cannot use none of them (to make 0)

0 is a natural number
so we know
the numbers must include 0 and 1
to be able to form all natural numbers

-.- Seems BC argued for a long time over the meaning of the statement

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		int n;
		scanf("%d",&n);
		bool win=false,flag=false;
		for(int i=0; i<n; i++) {
			int t;
			scanf("%d",&t);
			if(t==1)
				win=true;
			else if(t==0)
				flag=true;
		}
		if(win&&flag)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Problem link: HDU 5665 Lucky

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...