목록6603 (2)
황소개발자
import sys input = sys.stdin.readline def next_permutation(lst): n = len(lst) i = n - 1 while i > 0 and lst[i - 1] >= lst[i]: i -= 1 if i == 0: return [-1] j = n - 1 while lst[i - 1] >= lst[j]: j -= 1 tmp = lst[j] lst[j] = lst[i - 1] lst[i - 1] = tmp lst = lst[:i] + sorted(lst[i:]) return lst while True: s = input().strip() if s == '0': break lst = list(map(int, s.split())) n = lst[0] lst = lst[..
역시 갓파이썬이죠 파이썬엔 itertools 란 모듈이 있습니다. 모르시는분 이제 알고 가세요. 화끈합니다. import itertools import sys def sol(): while True: s = sys.stdin.readline() if s.strip() == "0": return lst = list(map(int, s.split())) lst = lst[1:] lst = list(map(str, lst)) combi = list(map(' '.join, list(itertools.combinations(lst, 6)))) for numbers in combi: print(numbers) print() sol() 우선 윗 코드는 정답코드입니다. 그리고 permutations, combinat..