标签:des style blog http color java os io
大意:
题意不好翻译,英文看懂也不是很麻烦,就不翻译了。
1 import java.io.*; 2 import java.math.*; 3 import java.util.*; 4 public class Main { 5 6 static BigInteger coe[][] = new BigInteger [3010][3010]; 7 public static void main(String[] args) throws IOException{ 8 Scanner cin = new Scanner(System.in); 9 BigInteger []a = new BigInteger[3010]; 10 BigInteger []c = new BigInteger[3010]; 11 int T; 12 T = cin.nextInt(); 13 while(T-- > 0){ 14 int n; 15 n = cin.nextInt(); 16 for(int i = 1; i <= n; ++i){ 17 a[i] = cin.nextBigInteger(); 18 } 19 BigInteger ans = BigInteger.ZERO; 20 c[0] = BigInteger.ONE; 21 ans = ans.add(c[0].multiply(a[n])); 22 int t = -1; 23 for(int i = 1; i < n; ++i){ 24 BigInteger t1 = BigInteger.valueOf(n).subtract(BigInteger.valueOf(i)); 25 BigInteger t2 = BigInteger.valueOf(i); 26 c[i] = c[i-1].multiply(t1).divide(t2); 27 ans = ans.add(c[i].multiply(a[n-i]).multiply(BigInteger.valueOf(t))); 28 t *= -1; 29 } 30 System.out.println(ans); 31 } 32 33 } 34 }
HDU 4927 Series 1 ( 组合+高精度),布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/Silence-AC/p/3906589.html