๋ฌธ์
https://www.acmicpc.net/problem/15651
15651๋ฒ: N๊ณผ M (3)
ํ ์ค์ ํ๋์ฉ ๋ฌธ์ ์ ์กฐ๊ฑด์ ๋ง์กฑํ๋ ์์ด์ ์ถ๋ ฅํ๋ค. ์ค๋ณต๋๋ ์์ด์ ์ฌ๋ฌ ๋ฒ ์ถ๋ ฅํ๋ฉด ์๋๋ฉฐ, ๊ฐ ์์ด์ ๊ณต๋ฐฑ์ผ๋ก ๊ตฌ๋ถํด์ ์ถ๋ ฅํด์ผ ํ๋ค. ์์ด์ ์ฌ์ ์์ผ๋ก ์ฆ๊ฐํ๋ ์์๋ก ์ถ๋ ฅํด
www.acmicpc.net
๋ด ๋ฌธ์ ํ์ด
n, m = map(int, input().split())
tmp = []
result = []
def dfs():
if len(tmp) == m:
print(' '.join(map(str, tmp)))
return
for i in range(1, n+1):
tmp.append(i)
dfs()
tmp.pop()
dfs()
๐ ๋ฐฑํธ๋ํน ๋ฌธ์ ! (https://seolhee2750.tistory.com/189 ์ฐธ๊ณ )
๐ก ํผ๋๋ฐฑ
- ๋ฐฑํธ๋ํน ์๊ณ ๋ฆฌ์ฆ ์ ์๊ณ ์์ผ๋ฉด ์ฝ๊ฒ ํ ์ ์๋ ๋ฌธ์ !
'4๏ธโฃ Python > Problem Solving' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python Algorithm] ๊ณตํต ๋ถ๋ถ ๋ฌธ์์ด BOJ #5582 (0) | 2022.05.24 |
---|---|
[Python Algorithm] N๊ณผ M (4) BOJ #15652 (0) | 2022.02.15 |
[Python Algorithm] N๊ณผ M (2) BOJ #15650 (0) | 2022.02.15 |
[Python Algorithm] N๊ณผ M (1) BOJ #15649 (0) | 2022.02.15 |
[Python Algorithm] Q-์ธ๋ฑ์ค BOJ #13333 (0) | 2022.02.10 |
๋๊ธ