๋ฌธ์
https://www.acmicpc.net/problem/15650
15650๋ฒ: N๊ณผ M (2)
ํ ์ค์ ํ๋์ฉ ๋ฌธ์ ์ ์กฐ๊ฑด์ ๋ง์กฑํ๋ ์์ด์ ์ถ๋ ฅํ๋ค. ์ค๋ณต๋๋ ์์ด์ ์ฌ๋ฌ ๋ฒ ์ถ๋ ฅํ๋ฉด ์๋๋ฉฐ, ๊ฐ ์์ด์ ๊ณต๋ฐฑ์ผ๋ก ๊ตฌ๋ถํด์ ์ถ๋ ฅํด์ผ ํ๋ค. ์์ด์ ์ฌ์ ์์ผ๋ก ์ฆ๊ฐํ๋ ์์๋ก ์ถ๋ ฅํด
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] N๊ณผ M (4) BOJ #15652 (0) | 2022.02.15 |
---|---|
[Python Algorithm] N๊ณผ M (3) BOJ #15651 (0) | 2022.02.15 |
[Python Algorithm] N๊ณผ M (1) BOJ #15649 (0) | 2022.02.15 |
[Python Algorithm] Q-์ธ๋ฑ์ค BOJ #13333 (0) | 2022.02.10 |
[Python Algorithm] ๊ณ๋จ ์ค๋ฅด๊ธฐ BOJ #2579 (0) | 2022.02.04 |
๋๊ธ