### Disc game prize fund题号：121 难度： 35 中英对照

A bag contains one red disc and one blue disc. In a game of chance a player takes a disc at random and its colour is noted. After each turn the disc is returned to the bag, an extra red disc is added, and another disc is taken at random.

The player pays £1 to play and wins if they have taken more blue discs than red discs at the end of the game.

If the game is played for four turns, the probability of a player winning is exactly 11/120, and so the maximum prize fund the banker should allocate for winning in this game would be £10 before they would expect to incur a loss. Note that any payout will be a whole number of pounds and also includes the original £1 paid to play the game, so in the example given the player actually wins £9.

Find the maximum prize fund that should be allocated to a single game in which fifteen turns are played.

### Code

import java.math.*;
public final class p121 {
public static void main(String[] args) {
long start=System.nanoTime();
String result = run();
long end=System.nanoTime();
System.out.println(result);
System.out.println( (end-start)/1000000 + "ms" );
}

static public String run(){
BigInteger a[][]=new BigInteger[22][22];
for(int i=0;i<22;i++) a[0][i]=BigInteger.ZERO;
final int N=15;
a[0][0]=BigInteger.ONE;
for(int i=1;i<=N;i++){
a[i][0]=BigInteger.valueOf(i).multiply(a[i-1][0]);
for(int j=1;j<i;j++){
a[i-1][j-1]);
}
a[i][i]=BigInteger.ONE;
}
BigInteger sum=BigInteger.ZERO,cnt=BigInteger.ZERO;
for(int j=0;j<=N;j++){
int red=N-j;

2269