시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 2101 631 461 30.013%

문제

창영이는 방 청소를 하다가 자와 각도기를 발견했다. 다음날 창영이는 학교에 자와 각도기를 들고 갔고, 현우와 "작도 대결"을 하려고 한다.

창영이는 각도기와 자를 이용해서 만들 수 있는 각을 알고 있고, 두 각을 합하거나 빼서 새로운 각을 만드는 방법을 알고 있다. 현우가 어떤 각도를 외치면, 창영이는 자와 각도기를 이용해서 현우가 외친 각도를 작도해야 한다. 작도할 때는 새로운 각을 이용해서 또다른 새로운 각을 만드는 것도 가능하다.

현우가 외치는 각도를 창영이가 만들 수 있는지 없는지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 창영이가 만드는 방법을 알고 있는 각의 수 N과 현우가 외친 각의 개수 K가 주어진다. (1 ≤ N, K ≤ 10)

둘째 줄에는 창영이가 만들 수 있는 각이 주어진다. 모든 각도는 360보다 작다.

셋째 줄에는 현우가 외친 각이 주어진다. 이 각도 360보다 작다.

출력

현우가 외친 각도를 창영이가 만들 수 있다면 YES를, 없다면 NO를 입력으로 주어진 순서대로 한 줄에 하나씩 출력한다.

예제 입력 1

2 1
30 70
40

예제 출력 1

YES

힌트

70도를 만들고, 30도를 빼서 40도를 만들면 된다.

W3sicHJvYmxlbV9pZCI6IjI5MTYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM3OTBcdWM2NDAgXHVhYzAxXHViM2M0XHVhZTMwIiwiZGVzY3JpcHRpb24iOiI8cD5cdWNjM2RcdWM2MDFcdWM3NzRcdWIyOTQgXHViYzI5IFx1Y2NhZFx1YzE4Y1x1Yjk3YyBcdWQ1NThcdWIyZTRcdWFjMDAgXHVjNzkwXHVjNjQwIFx1YWMwMVx1YjNjNFx1YWUzMFx1Yjk3YyBcdWJjMWNcdWFjYWNcdWQ1ODhcdWIyZTQuIFx1YjJlNFx1Yzc0Y1x1YjBhMCBcdWNjM2RcdWM2MDFcdWM3NzRcdWIyOTQgXHVk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