Chef and Numbers
All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given some integers in the range between 1 and N. You have to answer Q queries, each query is given by number X, you have to tell whether you can write number X as a sum of allowed numbers. You can use an allowed integer zero or multiple times.
The first line contains three integer numbers N and K, Q, where K denotes number of allowed integers, Q denotes number of queries. The second line containing K distinct integers Fi - allowed numbers.
Each of the next Q lines containing one integer number X.
For each query output "Yes" or "No" (without quotess) in separate line.
- 1 ≤ N, K, Q, X ≤ 200,000
- 1 ≤ Fi ≤ N
Input: 4 2 3 2 4 2 8 5 Output: Yes Yes No
Example case 1. 2 = 2
Example case 2. 8 = 2 + 2 + 4
Example case 3. 5 can't be sum of any number of addends 2 and 4
|Tags||cook77 fft medium mgch|
|Time Limit:||1.5 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.4, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions