Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

杨氏矩阵+钩子公式+java高精度

Posted by zorulee at 2017-09-21 22:15:45 on Problem 1825
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator