August 25, 2021
import sys
input = sys.stdin.readline
from collections import deque
a, b, c = map(int, input().split())
limit = [a, b, c]
visit = [[[False] * (c + 1) for _ in range(b + 1)] for _ in range(a + 1)]
possible = [0] * (c + 1)
def move(curr, _from, _to):
temp = [curr[0], curr[1], curr[2]]
# from에서 to로 부어도 to의 limit을 넘지 않는다면
if curr[_from] + curr[_to] <= limit[_to]:
temp[_to] = temp[_from] + temp[_to]
temp[_from] = 0
else:
temp[_from] -= limit[_to] - temp[_to]
temp[_to] = limit[_to]
return temp
def bfs():
# 리스트로 한 번 더 감싸야 한다.
queue = deque([[0, 0, limit[2]]])
visit[0][0][limit[2]] = True
while queue:
curr = queue.popleft()
# A 물병이 비어있다면
if curr[0] == 0:
possible[curr[2]] = True
for _from in range(3):
for _to in range(3):
# 자기 자신이면 변화 없음
if _from == _to:
continue
next = move(curr, _from, _to)
if not visit[next[0]][next[1]][next[2]]:
visit[next[0]][next[1]][next[2]] = True
queue.append(next)
bfs()
for i in range(c + 1):
if possible[i]:
print(i, end=' ')