💻 하나씩 차곡차곡/백준알고리즘 (Python,Java)
백준 1759번 파이썬
뚜루리
2024. 10. 10. 00:00
728x90
320x100
구현
from itertools import combinations
mo_list = ['a', 'e', 'i', 'o', 'u']
def is_possible(word):
global L, arr
mo_cnt = 0
for w in word:
mo_cnt += (w in mo_list)
ja_cnt = chose_num - mo_cnt
return (mo_cnt >=1 and ja_cnt >= 2)
chose_num , total_num = map(int, input().split())
arr = input().split()
arr.sort()
for word in combinations(arr, chose_num):
if is_possible(word):
print(''.join(word))
- 조합 알고리즘을 사용함.
- combinations 함수를 이용함.
728x90
320x100