Series 1
As a couple of examples, it is easy to think of a combination of C (n,m) ==c[n,n-m), which is the middle symmetry of the coefficients. This problem is the high-precision combinatorial number, Java seconds.
TIME:1825MS, close to the time limit, and if n is slightly larger, time out.
1 Importjava.math.*;2 ImportJava.util.*;3 ImportJava.io.*;4 Importjava.text.*;5 6 Public classMain7 {8 Static intms=3005;9 Public Static voidMain (string[] args)Ten { OneScanner cin=NewScanner (NewBufferedinputstream (system.in)); A int[] A=New int[MS]; - intT,n; -t=cin.nextint (); the while(t-->0) - { -n=cin.nextint (); - for(inti=0;i<n;i++) +a[i]=cin.nextint (); -BigInteger ans=biginteger.valueof (a[n-1]); +BigInteger res=Biginteger.one; ABigInteger flag=biginteger.valueof (-1); atBigInteger t=Biginteger.one; -N=n-1; - for(inti=1,j=n;i<=n;i++,j--) - { -res=res.multiply (Biginteger.valueof (j)). Divide (biginteger.valueof (i)); -T=res.multiply (flag) Multiply (biginteger.valueof (a[j-1])); inFlag=flag.multiply (biginteger.valueof (-1)); -ans=Ans.add (t); to } + System.out.println (ans); - } the cin.close (); * } $}
Series 1 Java second number of combinations