Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
杨氏矩阵+钩子公式+java高精度import java.math.*; import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); BigInteger num[]=new BigInteger[25]; BigInteger hoc[]=new BigInteger[250]; BigInteger x,y,z; int n; while(sc.hasNext()){ n=sc.nextInt(); for(int i=1;i<=n;++i) num[i]=sc.nextBigInteger(); for(int i=0;i<250;++i) hoc[i]=BigInteger.ZERO; int cnt=0; for(int i=1;i<=n;++i){ for(BigInteger j=BigInteger.ONE;j.compareTo(num[i])<=0;j=j.add(BigInteger.ONE)){ ++cnt; for(int k=i+1;k<=n;++k){ if(num[k].compareTo(j)>=0) hoc[cnt]=hoc[cnt].add(BigInteger.ONE); else break; } hoc[cnt]=hoc[cnt].add(num[i].subtract(j).add(BigInteger.ONE)); } } x=y=BigInteger.ONE; for(int i=1;i<=cnt;++i){ x=x.multiply(BigInteger.valueOf(i)); y=y.multiply(hoc[i]); z=x.gcd(y); x=x.divide(z); y=y.divide(z); } System.out.println(x.divide(y)); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator