Skip to content

Commit

Permalink
Add kattis prob kutevi in python3 + notes
Browse files Browse the repository at this point in the history
  • Loading branch information
iandioch committed Apr 11, 2018
1 parent ea437a4 commit baacb3c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions kattis/kutevi/notes.md
@@ -0,0 +1 @@
Build a queue of angles as you find new ones you can create. For each item in the queue, add any new angles you can create by combining this angle and one of the given ones.
28 changes: 28 additions & 0 deletions kattis/kutevi/solution.py
@@ -0,0 +1,28 @@
from collections import deque

n, m = map(int, input().split())

poss = [False for _ in range(360)]

given = list(map(int, input().split()))
q = deque()
q.append(given[0])
while len(q):
a = q.pop()
if poss[a]:
continue
poss[a] = True
for o in given:
b = abs(a - o)
if not poss[b]:
q.append(b)
c = (a+o)%360
if not poss[c]:
q.append(c)

for a in input().split():
ok = poss[int(a)]
if ok:
print('YES')
else:
print('NO')

0 comments on commit baacb3c

Please sign in to comment.