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