forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswe2817.java
More file actions
50 lines (36 loc) · 975 Bytes
/
swe2817.java
File metadata and controls
50 lines (36 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.Scanner;
public class swe2817 {
static Scanner sc = new Scanner(System.in);
static int Arr[];
static int K;
static int N;
static int answer=0;
public static void main(String[] args) {
int t = sc.nextInt();
//N개의 퀸이 N*N배열
for(int T=1; T<=t; T++) {
N = sc.nextInt();
K = sc.nextInt();
Arr = new int[N+1];
answer = 0;
//입력
for(int i=1; i<=N; i++)
{
Arr[i] = sc.nextInt();
}
//시작
for(int i=1; i<=N; i++)
solution(i,0);
System.out.println("#" + T + " " + answer);
}
}
public static void solution(int start, int count)
{
count += Arr[start];
//종료 시점
if(count == K)
answer++;
for(int j=start+1; j<=N; j++)
solution(j, count);
}
}