标签:des style http java os io for ar
大意:
题意不好翻译,英文看懂也不是很麻烦,就不翻译了。
import java.io.*; import java.math.*; import java.util.*; public class Main { static BigInteger coe[][] = new BigInteger [3010][3010]; public static void main(String[] args) throws IOException{ Scanner cin = new Scanner(System.in); BigInteger []a = new BigInteger[3010]; BigInteger []c = new BigInteger[3010]; int T; T = cin.nextInt(); while(T-- > 0){ int n; n = cin.nextInt(); for(int i = 1; i <= n; ++i){ a[i] = cin.nextBigInteger(); } BigInteger ans = BigInteger.ZERO; c[0] = BigInteger.ONE; ans = ans.add(c[0].multiply(a[n])); int t = -1; for(int i = 1; i < n; ++i){ BigInteger t1 = BigInteger.valueOf(n).subtract(BigInteger.valueOf(i)); BigInteger t2 = BigInteger.valueOf(i); c[i] = c[i-1].multiply(t1).divide(t2); ans = ans.add(c[i].multiply(a[n-i]).multiply(BigInteger.valueOf(t))); t *= -1; } System.out.println(ans); } } }
HDU 4927 Series 1 ( 组合+高精度),布布扣,bubuko.com
标签:des style http java os io for ar
原文地址:http://blog.csdn.net/xuechelingxiao/article/details/38511157