Skip to content

Commit 23c6002

Browse files
committed
백준 15652번 N과 M (4)
문제 링크: https://www.acmicpc.net/problem/15652
1 parent 252f1b4 commit 23c6002

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

백준 15652번 N과 M (4)/main.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
from typing import List
3+
4+
5+
def solve():
6+
N, M = map(int, sys.stdin.readline().strip().split(' '))
7+
dt: List[int] = [v for v in range(1, N + 1)]
8+
my_perm(0, dt, [], M, fn_found)
9+
10+
11+
def fn_found(perms: List[int]):
12+
perms: List[str] = map(lambda x: str(x) + ' ', perms)
13+
perm = ''.join(perms).strip()
14+
print(perm)
15+
16+
17+
def my_perm(bgn, dt, perms: List[int], length, fn_found):
18+
if len(perms) == length:
19+
fn_found(perms)
20+
return
21+
22+
for i in range(bgn, len(dt)):
23+
perms.append(dt[i])
24+
my_perm(i, dt, perms, length, fn_found)
25+
perms.pop()
26+
27+
28+
if __name__ == '__main__':
29+
solve()

0 commit comments

Comments
 (0)