// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class Combi {
    private static int calc(int[] votes, int target, boolean[] use, int ix) {
        int res = 0;
        if(ix < votes.length) {
            use[ix] = false;
            res += calc(votes, target, use, ix + 1);
            use[ix] = true;
            res += calc(votes, target, use, ix + 1);
        } else {
            int tmp = 0;
            for(int i = 0; i < votes.length; i++) {
                if(use[i]) {
                    tmp += votes[i];
                }
            }
            res = (tmp >= target) ? 1 : 0;
        } 
        return res;
    }
    private static int calc(int[] votes, int target)
    {
        return calc(votes, target, new boolean[votes.length], 0);
    }
    public static void main(String[] args) {
        int[] votes = { 29, 29, 29, 29, 27, 27,
                        14, 13, 12, 12, 12, 12, 12, 10, 10, 10,
                        7, 7, 7, 7, 7,
                        4, 4, 4, 4, 4, 3 };
        long t1 = System.currentTimeMillis();
        System.out.println(calc(votes, 255));
        long t2 = System.currentTimeMillis();
        System.out.println(t2 - t1);
    }
}
