package com.ssafy.off;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Baekjoon_3040_백설공주와일곱난쟁이 {
static final int N = 7;
static int[] numbers;
static int[] result;
static boolean isSelected[];
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
numbers = new int[9];
result = new int[7];
for (int i = 0; i < 9; i++) {
numbers[i] = Integer.parseInt(br.readLine());
}
comb(0,0);
}
private static void comb(int cnt, int start) {
if(cnt == N) {
int sum = 0;
for (int i = 0; i < result.length; i++) {
sum += result[i];
}
if(sum==100) {
//Arrays.sort(result);
for (int i = 0; i < result.length; i++) {
System.out.println(result[i]);
}
}
return;
}
else {
for (int i = start; i < 9; i++) {
result[cnt] = numbers[i];
comb(cnt+1, i+1);
}
}
}
}
'Algorithm' 카테고리의 다른 글
[백준] JAVA - 2961.도영이가 만든 맛있는 음식 (0) | 2021.02.16 |
---|---|
[SWEA] JAVA - 6808. 규영이와 인영이의 카드게임 (0) | 2021.02.15 |
[백준] JAVA - 7569.토마토 (0) | 2021.02.13 |
[백준] JAVA - 3055.탈출 (0) | 2021.02.13 |
[백준] JAVA - 1520.내리막길 (0) | 2021.02.13 |