Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kattis prob kutevi in python3 + notes
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |