문제링크
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main_2309 {
static int arr[] = new int[9];
static int arr2[] = new int[7];
static int result[] = new int[7];
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<9;i++)
arr[i] = Integer.parseInt(br.readLine());
combination(0, 0);
Arrays.sort(result);
for(int i=0;i<7;i++)
System.out.println(result[i]);
}
static void combination(int cnt,int start) {
if(cnt == 7) {
int sum = 0;
for(int i=0;i<7;i++) {
sum+= arr2[i];
}
if(sum == 100) {
for(int i=0;i<7;i++)
result[i] = arr2[i];
}
return;
}
for(int i=start;i<9;i++) {
arr2[cnt] = arr[i];
combination(cnt+1, i+1);
}
}
}
'알고리즘 > 백준' 카테고리의 다른 글
[JAVA][C++]백준_2164_카드2 (0) | 2021.02.10 |
---|---|
[JAVA]백준_10819_차이를 최대로 (0) | 2021.02.07 |
[JAVA]백준_1302_베스트셀러 (0) | 2021.02.07 |
[JAVA]백준_10974_모든 순열 (0) | 2021.02.07 |
[JAVA]백준_5597_과제 안 내신 분..? (0) | 2021.02.07 |