import java.util.Scanner;
public class Main {
static int n, k;
static int su[] = new int [101];
static int arr[] = new int [101];
static int flag=0;
static int way = 0;
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int i;
n = scan.nextInt();
k = scan.nextInt();
for (i = 1; i <= k; i++) {
su[i] = scan.nextInt();
}
f(1, 1);
if(way==0) {
System.out.printf("NONE");
}
}
private static void f(int level, int s) {
int i;
if (level > k) {
if(flag==1) {
output();
way=1;
flag=0;
}
check();
return;
}
for (i = s; i <= n; i++) {
arr[level] = i;
f(level + 1, i + 1);
}
}
private static void check() {
// TODO Auto-generated method stub
int i;
for (i = 1; i <= k; i++) {
if(arr[i]!=su[i]) return;
}
flag =1;
}
private static void output() {
int i;
for (i = 1; i <= k; i++) {
System.out.printf("%d ", arr[i]);
}
}
}
http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=762&sca=2080
'정올문제소스코드' 카테고리의 다른 글
Jungol_Beginner_도형만들기1 (0) | 2022.12.24 |
---|---|
2567 : 싸이클 (0) | 2022.03.18 |
2817 : 로또(Lotto) (0) | 2022.03.18 |
1021 : 장난감조립 (0) | 2021.12.05 |
1459 : 숫자고르기 (0) | 2021.12.05 |