From charlesreid1

Code: https://charlesreid1.com:3000/cs/euler/src/master/scratch/Round5_150-160/158

$ cat Problem158.java
public class Problem158 {
	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static int pow(int b, int p) {
		int result = b;
		for(int i=2; i<=p; i++) {
			result *= b;
		}
		return result;
	}

	public static String solve() {
		int m = 26;
		BinomialDP b = new BinomialDP(m);

		long p = 0;
		long priorconfigs = 1;
		for(int n=3; n<=26; n++) {

			long binom = (long)( b.binomial(26,n) );
			long configs = (long)(priorconfigs + (pow(2,n-1)-1));
			long pnew = binom*configs;

			//System.out.printf("%12d\t%12d\t%12d\t%12d\n",n,binom,configs,pnew);

			p = Math.max(p,pnew);
			priorconfigs = configs;
		}
		return Long.toString(p);
	}
}


Flags