문제링크
https://www.acmicpc.net/problem/3040
import java.util.Scanner;
public class Main_3040 {
static int arr[] = new int[9];
static int res[] = new int[7];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int i=0;i<9;i++) {
arr[i] = sc.nextInt();
}
comb(0,0);
}
static void comb(int cnt,int start) {
if(cnt == 7) {
int sum = 0;
for(int i=0;i<7;i++)
sum += res[i];
if(sum == 100) {
for(int i=0;i<7;i++)
System.out.println(res[i]);
}
return;
}
for(int i=start;i<9;i++) {
res[cnt] = arr[i];
comb(cnt+1, i+1);
}
}
}
'알고리즘 > 백준' 카테고리의 다른 글
[JAVA]백준_10026_적록색약 (0) | 2021.02.15 |
---|---|
[JAVA]백준_11723_집합 (0) | 2021.02.15 |
[JAVA]백준_11559_뿌요뿌요 (0) | 2021.02.15 |
[JAVA]백준_1697_숨바꼭질 (0) | 2021.02.14 |
[JAVA]백준_2563_색종이 (0) | 2021.02.13 |