본문 바로가기

파이썬

[BOJ][PYTHON] 6603번 로또

https://www.acmicpc.net/problem/6603

 

6603번: 로또

입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있다. 첫 번째 수는 k (6 < k < 13)이고, 다음 k개 수는 집합 S에 포함되는 수이다. S의 원소는 오름차순으로

www.acmicpc.net

 

<코드>

from itertools import combinations
import sys
input = sys.stdin.readline

while True:
    lst = list(map(int, input().split()))
    n = lst[0]
    if n == 0:
        break

    new_lst = lst[1::]
    for i in list(combinations(new_lst, 6)):
        print(*i)
    print()

 

조합문제여서 combinations쓰고 for문으로 출력하면 된다!