ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
var n, m int
reader := bufio.NewReader(os.Stdin)
fmt.Fscanln(reader, &n, &m)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var result = make([]int, m+1)
sequence(writer, result, 0, n, m)
}
func sequence(writer *bufio.Writer, result []int, index, n, m int) {
if index == m {
for i := 0; i < m; i++ {
fmt.Fprintf(writer, "%d ", result[i])
}
fmt.Fprint(writer, "\n")
return
}
for i := 1; i < n+1; i++ {
if index > 0 && result[index-1] > i {
continue
}
result[index] = i
sequence(writer, result, index+1, n, m)
}
}
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 2580๋ฒ / ์ค๋์ฟ [Go] (0) | 2020.07.24 |
---|---|
BOJ / 9663๋ฒ / N-Queen [Go] (0) | 2020.07.23 |
BOJ / 15651๋ฒ / N๊ณผ M (3) [Go] (0) | 2020.07.21 |
BOJ / 15650๋ฒ / N๊ณผ M (2) [Go] (0) | 2020.07.20 |
BOJ / 15649๋ฒ / N๊ณผ M (1) [Go] (0) | 2020.07.19 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- Macbook pro 2012 mid 13
- ํ๋ก์ด๋์์ฌ
- dfs
- python3
- ballet
- MongoDB
- ์๊ฐ๊ต์ฒด
- dp
- ์คํ
- BOJ
- ๋ถํ ์ ๋ณต
- Algorithm
- AWS
- go
- BFS
- ํ
- ๋ฐ๋
- ๋งฅ๋ถํ๋ก
- ๋ชฝ๊ณ ๋๋น
- Golang
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ๋งฅ๋ถ
- ๋ธ๋ฃจํธํฌ์ค
- baekjoon
- ์ด๋ถํ์
- ๋ฐฑ์ค
- java
- ํด์๋งต
- ์๊ณ ๋ฆฌ์ฆ
- ์๋ฐ
- Total
- Today
- Yesterday