#P7774. [COCI 2009/2010 #2] KUTEVI

    ID: 8841 远端评测题 1000ms 32MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>模拟动态规划 DP2009枚举哈希 hashingCOCI(克罗地亚)

[COCI 2009/2010 #2] KUTEVI

Background

This problem is from $\texttt{COCI 2009-2010}\ 2^\texttt{nd}\ \texttt{round}\ \text{T3 KUTEVI}$.

The score settings follow the original problem, with a full score of 7070.

Problem Description

You are given NN angles (the ii-th angle is denoted as aia_i) as initial angles, and also given MM angles (the ii-th angle is denoted as bib_i) as target angles.

For each bib_i, determine whether it can be obtained by performing addition and subtraction among some of the aia_i.

Note that the same aia_i can be used multiple times, or not used at all.

Input Format

The first line contains two positive integers N,MN, M.

The second line contains NN positive integers, where the ii-th number is aia_i.

The third line contains MM positive integers, where the ii-th number is bib_i.

Output Format

Output MM lines. On the ii-th line, if bib_i can be obtained by performing addition and subtraction among some of the aia_i, output YES; otherwise output NO.

2 1
30 70
40
YES
1 1
100
60
YES
3 2
10 20 30
5 70
NO
YES

Hint

Sample Explanation

Explanation for sample 11:

7030=4070^\circ - 30^\circ = 40^\circ.

Explanation for sample 22:

15×100=1500=6015 \times 100^\circ = 1500^\circ = 60^\circ.

Constraints and Notes

1N,M101 \leq N, M \leq 10, 0<ai,bi<3600 < a_i, b_i < 360.

Translated by ChatGPT 5