알고리즘/DFS | BFS
파이썬 | 백준 | 6603 | 로또 | 조합(combinations)
cha-n
2020. 8. 14. 13:56
solution
1. K개 중 6개 → 조합 from itertools import combinations
# 6603, 로또
import sys
from itertools import combinations
lot = []
while True:
lot = list(map(int, sys.stdin.readline().split()))
if lot[0] == 0 and len(lot) == 1: # 0이면 실행 종료
break
lot_com = list(combinations(lot[1:], 6)) # 6개 뽑음
for lot_com_ in lot_com:
print(*lot_com_)
print()
29380KB
64ms
문제 출처 https://www.acmicpc.net/problem/6603
6603번: 로또
문제 독일 로또는 {1, 2, ..., 49}에서 수 6개를 고른다. 로또 번호를 선택하는데 사용되는 가장 유명한 전략은 49가지 수 중 k(k>6)개의 수를 골라 집합 S를 만든 다음 그 수만 가지고 번호를 선택하는
www.acmicpc.net