ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ 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
- BOJ
- ์๊ณ ๋ฆฌ์ฆ
- ๋งฅ๋ถ
- ํ๋ก์ด๋์์ฌ
- baekjoon
- ์คํ
- ballet
- ์๊ฐ๊ต์ฒด
- ๋ชฝ๊ณ ๋๋น
- ํด์๋งต
- ๋ธ๋ฃจํธํฌ์ค
- python3
- ์ด๋ถํ์
- java
- go
- AWS
- dp
- Macbook pro 2012 mid 13
- ๋ฐ๋
- BFS
- ์๋ฐ
- Algorithm
- ๋ฐฑ์ค
- MongoDB
- ํ
- Golang
- ๋งฅ๋ถํ๋ก
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ๋ถํ ์ ๋ณต
- dfs
- Total
- Today
- Yesterday