코드
import java.io.*;
import java.util.*;
public class Main {
static int n;
static int s;
static int[] elements;
static int count = 0;
public static void main(String[] args) {
input();
func(0, 0);
if (s == 0) {
--count;
}
System.out.println(count);
}
static void input() {
Scanner scanner = new Scanner(System.in);
n = scanner.nextInt();
s = scanner.nextInt();
elements = new int[n];
for (int i = 0; i < n; ++i) {
elements[i] = scanner.nextInt();
}
scanner.close();
}
static void func(int rec, int value) {
if (rec == n) {
if (value == s) ++count;
return;
}
func(rec + 1, value + elements[rec]);
func(rec + 1, value);
}
}