You are viewing a single comment's thread. Return to all comments →
Java 8 solution:
public static int solve(List<Integer> a) { int even_number=0; int odd_number=0; int i; for(i=0;i<a.size();++i) { if(a.get(i)%2==0) { ++even_number; } else { ++odd_number; } } BigInteger even_comb = BigInteger.valueOf(2).pow(even_number).subtract(BigInteger.valueOf(1)).mod(BigInteger.valueOf(1000000007)); BigInteger odd_comb =odd_number>0? BigInteger.valueOf(2).pow(odd_number-1).subtract(BigInteger.valueOf(1)).mod(BigInteger.valueOf(1000000007)):BigInteger.valueOf(0); BigInteger total_comb = even_comb.multiply(odd_comb).mod(BigInteger.valueOf(1000000007)); BigInteger ans = even_comb.add(odd_comb).add(total_comb).mod(BigInteger.valueOf(1000000007)); return ans.intValue(); }
Seems like cookies are disabled on this browser, please enable them to open this website
A Chocolate Fiesta
You are viewing a single comment's thread. Return to all comments →
Java 8 solution: