반응형
https://www.acmicpc.net/problem/15651
package main
import (
"bufio"
"fmt"
"os"
)
var writer = bufio.NewWriter(os.Stdout)
var reader = bufio.NewReader(os.Stdin)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
func solve(arr []int, n, m int) {
if m == 0 {
for _, v := range arr {
printf("%d ", v)
}
printf("\n")
return
}
for i := 1; i <= n; i++ {
arr = append(arr, i)
solve(arr, n, m-1)
arr = arr[:len(arr)-1]
}
}
func main() {
defer writer.Flush()
var n, m int
scanf("%d %d\n", &n, &m)
arr := []int{}
solve(arr, n, m)
}
'Study > algorithms' 카테고리의 다른 글
[백준] 9663 N-Queen (0) | 2020.01.28 |
---|---|
[백준] 15652 N과 M (4) (0) | 2020.01.27 |
[백준] 15649 N과 M (1) (0) | 2020.01.26 |
[백준] 10814 나이순 정렬 (0) | 2020.01.25 |
[백준] 11651 좌표 정렬하기 2 (0) | 2020.01.25 |