世人若学我,如同入魔道
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
public class Main {
public static int[] vis =new int [1001];
public static Long sum = 0L;
public static int n = 0;
public static int[] arr = new int [1001];
public static void main(String[] args) throws IOException {
StreamTokenizer stk = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
while(stk.nextToken() != StreamTokenizer.TT_EOF) {
arr[n++] = (int) stk.nval;
}
dfs(0);
System.out.println(sum);
}
private static void dfs(int x) {
if(x > n - 1) {
for(int i = 0; i < n; i++) {
sum += vis[i] == 1 ? arr[i] : 0;
}
return;
}
vis[x] = 1;
dfs(x + 1);
vis[x] = 0;
vis[x] = 2;
dfs(x + 1);
vis[x] = 0;
}
}