Logo
(追記) (追記ここまで)

8008번 - Sums 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB144463840.000%

문제

We are given a set of positive integers A. Consider a set of non-negative integers A’, such that a number x belongs to A’ if and only if is a sum of some elements from A (the elements may be repeated). For example, if A={2,5,7}, then sample numbers belonging to the set A’ are: 0 (the sum of 0 elements), 2, 4 (2+2) and 12 (5+7 or 7+5 or 2+2+2+2+2+2); and the following do not belong to A’: 1 and 3.

Write a program which:

  • reads from the standard input the description of the set A and the sequence of numbers bi,
  • for each number bi determines whether it belongs to the set A’,
  • writes the result to the standard output.

입력

In the first line there is one integer n: the number of elements of the set A, 1 ≤ n ≤ 5,000. The following n lines contain the elements of the set A, one per line. In the (i+1)-st line there is one positive integer ai, 1 ≤ ai ≤ 50,000. A={a1,a2,…,an}, a1 < a2 < … < an.

In the (n+2)-nd line there is one integer k, 1 ≤ k ≤ 10,000. Each of the following k lines contains one integer in the range from 0 to 1,000,000,000, they are respectively the numbers b1,b2,…,bk.

출력

The output should consist of k lines. The i-th line should contain the word TAK ("yes" in Polish), if bi belongs to A’, and it should contain the word NIE ("no") otherwise.

제한

예제 입력 1

3
2
5
7
6
0
1
4
12
3
2

예제 출력 1

TAK
NIE
TAK
TAK
NIE
TAK

힌트

출처

Olympiad > Polish Olympiad in Informatics > POI 2002/2003 > Stage 3 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /