hdu 1261 字串数

指数型母函数应用!!!

import java.math.*; import java.util.*;

public class
Main {
    public static
int []a;
    public static
void main(String arg[]){ BigInteger [] p =new BigInteger[313];
        p[1]=BigInteger.ONE;
        int
i;
        for
(i=2;i<=312;i++){
            p[i] = p[i-1].multiply(BigInteger.valueOf(i));
        }

        Scanner
cin = new Scanner(System.in);
        a =new int[27];
        int
t,sum;
        while
(true){
            t = cin.nextInt();
            if
(t==0) break;
            sum=0;
            for
(i=0;i<t;i++){
                a[i]=cin.nextInt(); sum+=a[i];
            }

            BigInteger
ans = p[sum];
            for
(i=0;i<t;i++){ ans=ans.divide(p[a[i]]);
            }

            System
.out.println(ans.toString());
        }
    }
}

posted @ 2013-07-25 17:06  _随心所欲_  阅读(210)  评论(0编辑  收藏  举报