HDU 4927 Series 1 ( 组合+高精度)
大意:
题意不好翻译,英文看懂也不是非常麻烦,就不翻译了。
The zero-order series of A is A itself.
The first-order series of A is {B1, B2, . . . , Bn-1},where Bi = Ai+1 - Ai.
The ith-order series of A is the first-order series of its (i - 1)th-order series (2<=i<=n - 1).
Obviously, the (n - 1)th-order series of A is a single integer. Given A, figure out that integer.
For each test case:
The first line contains a single integer n(1<=n<=3000), which denotes the length of series A.
The second line consists of n integers, describing A1, A2, . . . , An. (0<=Ai<=105)
。
。非常无语
。。 比赛结束也没搞出来。
。
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 ( 组合+高精度)的更多相关文章
- HDU 4927 Series 1(高精度+杨辉三角)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4927 解题报告:对于n,结果如下: C(0,n-1) *A[n] - C(1,n-1) * A[n-1 ...
- HDU 4927 Series 1(推理+大数)
HDU 4927 Series 1 题目链接 题意:给定一个序列,要求不断求差值序列.直到剩一个,输出这个数字 思路:因为有高精度一步.所以要推理一下公式,事实上纸上模拟一下非常easy推出公式就是一 ...
- 2014多校第六场 1007 || HDU 4927 Series 1(杨辉三角组合数)
题目链接 题意 : n个数,每操作一次就变成n-1个数,最后变成一个数,输出这个数,操作是指后一个数减前一个数得到的数写下来. 思路 : 找出几个数,算得时候先不要算出来,用式子代替,例如: 1 2 ...
- 多校第六场 HDU 4927 JAVA大数类+模拟
HDU 4927 −ai,直到序列长度为1.输出最后的数. 思路:这题实在是太晕了,比赛的时候搞了四个小时,从T到WA,唉--对算组合还是不太了解啊.如今对组合算比較什么了-- import java ...
- hdu 4927 组合+公式
http://acm.hdu.edu.cn/showproblem.php?pid=4927 给定一个长度为n的序列a,每次生成一个新的序列,长度为n-1,新序列b中bi=ai+1−ai,直到序列长度 ...
- 【HDU - 4927】Series 1
BUPT2017 wintertraining(15) #5I 题意 输出序列A[1..n]的第n-1阶差分(一个整数). 题解 观察可知答案就是 \[ \sum_{i=0}^{n-1} {(-1)^ ...
- HDU 4927
http://acm.hdu.edu.cn/showproblem.php?pid=4927 直接模拟会超时,要在纸上写写推公式 A[n]*C(0,n-1) - A[n-1]*C(1,n-1) + ...
- hdu 1316 How many Fibs?(高精度斐波那契数)
// 大数继续 Problem Description Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn : ...
- hdu 1715 大菲波数(高精度数)
Problem Description Fibonacci数列,定义如下: f(1)=f(2)=1 f(n)=f(n-1)+f(n-2) n>=3. 计算第n项Fibonacci数值. Inpu ...
随机推荐
- XPath教程
XPath 简介 XPath 是一门在 XML 文档中查找信息的语言.XPath 可用来在 XML 文档中对元素和属性进行遍历. XPath 是 W3C XSLT 标准的主要元素,并且 XQuery ...
- OpenERP实施记录(9):销售一批电脑
本文是<OpenERP实施记录>系列文章的一部分. 前述的基础数据配置完成之后,我们就可以开始业务处理了. 1. 业务部门接到沃尔玛客户三台联想笔记本电脑的需求.销售 > Sales ...
- 为11gR2 Grid Infrastructure增加新的public网络
在某些环境下,运行11.2版本的RAC数据库的服务器上,连接了多个public网络,那么就会有如下的需求: 给其他的,或者说是新的public网络增加新的VIP地址. 在新的public网络上增加SC ...
- python接口自动化9-https请求(SSL)
前言 本来最新的requests库V2.13.0是支持https请求的,但是一般写脚本时候,我们会用抓包工具fiddler,这时候会报:requests.exceptions.SSLError: [S ...
- 有用的iOS网站地址
王巍 (@onevcat) 是一名 iOS 和 Unity3D 开发者,现旅居日本,正在寻求创意之源.http://swifter.tips/http://onevcat.com/2013/02/xc ...
- Js的在线代码编辑器:CodeMirror
github地址:https://github.com/codemirror/CodeMirror/tree/master/demo 里面包含需要的js.css文件以及大量的示例 官网:https:/ ...
- linux查找超过一定时间的文件,并批量删除
1.find . -maxdepth 4 -name "*-*" -mtime 3 -maxdepth的值决定是否对下面的子目录进行递归查找 -mtime 3表示查找刚好3天的: ...
- shell执行时文件命名导致的错误
1.脚本check_nginx.sh的内容如下: #!/bin/bash count=$(ps -ef | grep nginx | grep -v grep | wc -l) echo $count ...
- informatica powercenter学习笔记(一)
本文转摘:http://blog.itpub.net/22377317/viewspace-677137/ 1 informatica powercenter的下载: 方法一:去年我是在ORACLE ...
- Power Desginer系列01【转摘】
近期在做一个业务系统的分析和数据模型设计,工作这几年也做过好几个项目的数据库模型的设计,期间也算是积累了一定的经验吧,这次有机会就写写我的数据库模型设计过程与方法. 在 数据库设计中,设计的目标就是要 ...