-
boj)15651 - N과 M (3)PS/boj 2020. 11. 16. 16:18123456789101112131415161718192021222324252627282930313233343536373839import java.io.*;import java.util.Scanner;public class boj_15651 {static Scanner sc = new Scanner(System.in);static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));static int[] numbers = new int[10];static boolean[] v = new boolean[10];static int n, m;public static void main(String[] args) throws IOException {n = sc.nextInt();m = sc.nextInt();func(0);bw.flush();bw.close();}static void func(int k) throws IOException {if (k == m) {for (int i = 0; i < m; i++) {bw.append(numbers[i] + " ");}bw.newLine();return;}for (int i = 1; i <= n; i++) {numbers[k] = i;v[i] = true;func(k + 1);v[i] = false;}}}
cs - 백트래킹
- 기존에서 중복이 가능하단것만 바뀜
'PS > boj' 카테고리의 다른 글
boj)1654 - 랜선 자르기 (0) 2020.11.17 boj)5525 - IOIOI (0) 2020.11.17 boj)15650 - N과 M (2) (0) 2020.11.16 boj)15649 - N과 M (1) (0) 2020.11.16 boj)5904 - Moo 게임 (0) 2020.11.15