본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 14911번 궁합 쌍 찾기

by 현장 2024. 6. 8.

-Code

from itertools import combinations

nums = sorted(list(map(int, input().split())))
n = int(input())
res = []

for com in combinations(nums, 2):
    if sum(com) == n and com not in res:
        res.append(com)
        print(*com)

print(len(res))