Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- DP
- python
- level2
- programmers
- 파이썬
- 백준
- 코딩테스트
- BOJ
- level3
- N과M
- 구현
- 운영체제
- 재귀
- MYSQL
- level0
- 다익스트라
- 수학
- dfs
- BFS
- 프로그래머스
- 그리디
- level1
- 가상메모리
- 스택
- 딕셔너리
- 브루트포스
- 가상메모리 관리
- 힙
- 다이나믹 프로그래밍
- dict
Archives
- Today
- Total
동캄의 코딩도장
백준 10974 [모든 순열] 파이썬 본문
#10974
n=int(input())
s=[]
def dfs():
if len(s)==n:
print(' '.join(map(str,s)))
return
for i in range(1,n+1):
if i in s:
continue
s.append(i)
dfs()
s.pop()
dfs()
1부터 n까지 dfs문을 돌려서 순열을 출력하였다.
itertools.permutations() 라는 라이브러리 함수를 사용하면 더욱 쉽게 풀 수 있을거같다.
'코테 > BOJ' 카테고리의 다른 글
백준 9251 [LCS] 파이썬 (0) | 2021.12.14 |
---|---|
백준 6603 [로또] 파이썬 (0) | 2021.12.02 |
백준 15657 [N과M (8)] 파이썬 (0) | 2021.12.02 |
백준 15656 [N과M (7)] 파이썬 (0) | 2021.12.02 |
백준 15655 [N과 M (6)] 파이썬 (0) | 2021.12.02 |