COCI '09 Contest 2 #3 Kutevi

View as PDF

Submit solution


Points: 7
Time limit: 1.0s
Memory limit: 32M

Problem types

One day Mirko was cleaning up his room and found a straightedge and a compass. He went to the school the next day and challenged his friend Slavko to a geometric construction battle. Mirko knows how to construct some angles using the straightedge and compass and knows how to subtract and add any two angles he constructs. Slavko now shouts random angles and Mirko must draw them as fast as possible.

You are observing this battle and would like to know if Mirko can construct the angles Slavko shouts at all.

Input Specification

The first line of input contains two integers, N (1 \le N \le 10), number of angles Mirko knows how to construct initially and K (1 \le K \le 10), number of angles Slavko selected.

The second line of input contains N integers, all smaller than 360, the angles Mirko knows how to construct initially.

The third line contains K integers, all smaller than 360, the angles Slavko selected.

Output Specification

Output consists of K lines, one for each angle Slavko selected. The i-th line should contain YES if Mirko can construct the i-th angle, and NO otherwise.

Sample Input 1

2 1
30 70
40

Sample Output 1

YES

Explanation for Sample Output 1

Subtracting 30^\circ from 70^\circ yields 70^\circ - 30^\circ = 40^\circ.

Sample Input 2

1 1
100
60

Sample Output 2

YES

Explanation for Sample Output 2

Adding 100^\circ 15 times yields 1500^\circ, also known as 60^\circ.

Sample Input 3

3 2
10 20 30
5 70

Sample Output 3

NO
YES

Comments

There are no comments at the moment.