题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4927

解题报告:对于n,结果如下:

C(0,n-1) *A[n] - C(1,n-1) * A[n-1] + C(2,n-1) * A[n-2] - C(3,n-1) * A[n-3] ....... C(n-1,n-1) * A[1];

n <= 3000,到了后面二项式会很大,因为要用到高精度的乘法和除法,所以直接用java的大数类写了,简单多了。

 import java.math.BigInteger;
import java.util.*; public class Main
{
public static BigInteger ans,a,b,flag,temp;
public static BigInteger[] A = new BigInteger[3005];
public static void main(String[] argv)
{ Scanner input = new Scanner(System.in);
int T,n;
T = input.nextInt();
for(int t = 0;t < T;++t)
{
n = input.nextInt();
ans = ans.valueOf(0);
a = a.valueOf(1);
b = a;
for(int i = 1;i <= n;++i)
{
A[i] = input.nextBigInteger();
A[i] = A[i].multiply(a);
a = a.multiply(a.valueOf(n-i));
a = a.divide(a.valueOf(i));
}
flag = flag.valueOf(1);
for(int i = n;i >= 1;--i)
{
A[i] = A[i].multiply(flag);
ans = ans.add(A[i]);
flag = flag.multiply(flag.valueOf(-1));
}
System.out.println(ans);
}
}
}

HDU 4927 Series 1(高精度+杨辉三角)的更多相关文章

  1. 2014多校第六场 1007 || HDU 4927 Series 1(杨辉三角组合数)

    题目链接 题意 : n个数,每操作一次就变成n-1个数,最后变成一个数,输出这个数,操作是指后一个数减前一个数得到的数写下来. 思路 : 找出几个数,算得时候先不要算出来,用式子代替,例如: 1 2 ...

  2. hdu 2032 一维数组实现杨辉三角

    杨辉三角 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  3. HDU - 5015 233 Matrix(杨辉三角/前缀+矩阵快速幂)

    233 Matrix In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23 ...

  4. HDU 4927 Series 1 ( 组合+高精度)

    pid=4927">Series 1 大意: 题意不好翻译,英文看懂也不是非常麻烦,就不翻译了. Problem Description Let A be an integral se ...

  5. HDU 2032 杨辉三角

    http://acm.hdu.edu.cn/showproblem.php?pid=2032 Problem Description 还记得中学时候学过的杨辉三角吗?具体的定义这里不再描述,你可以参考 ...

  6. HDU 6129 Just do it(杨辉三角)

    http://acm.hdu.edu.cn/showproblem.php?pid=6129 题意: 给出数组a,并且bi=a1^a2^a3...^ai,并且现在会重复m次,求出最后的b数组. 思路: ...

  7. HDOJ(HDU) 1799 循环多少次?(另类杨辉三角)

    Problem Description 我们知道,在编程中,我们时常需要考虑到时间复杂度,特别是对于循环的部分.例如, 如果代码中出现 for(i=1;i<=n;i++) OP ; 那么做了n次 ...

  8. HDU - 6129 :Just do it (杨辉三角)

    There is a nonnegative integer sequence a 1...n  a1...n of length n n . HazelFan wants to do a type ...

  9. hdu 5698(杨辉三角的性质+逆元)

    ---恢复内容开始--- 瞬间移动 Accepts: 1018 Submissions: 3620 Time Limit: 4000/2000 MS (Java/Others) Memory Limi ...

随机推荐

  1. 电脑技巧:Win8/Win10无法打开这个应用|无法使用内置管理员账户的完美解决方法

    现在装win10系统的同伴越来越多了,相比于win7,win10在某些设置方面也有些变化,比如我们在使用win8或者win10时,会碰到如图所示的对话框: Windows10/Windows8无法使用 ...

  2. python--文件删除、判断目录存在、字符串替换

    昨晚笔试了金山WPS的测试开发卷,做个笔记(但不是答案,只是我的想法),关于文件和字符串的处理正在写入与完善至上一篇的博客中,现在题目如下: 1.使用脚本语言删除E:\abc目录下的所有文件: 利用o ...

  3. Eclipse中修改Web项目的URL访问路径

    背景 访问路径,也就是指在浏览器中访问该web系统时的根路径,比如http://localhost:8080/xxxx/index.jsp  这里的xxxx,也就是request.getContext ...

  4. PyCharm光标变粗的解决办法

    pycharm中光标变粗,如下: 此时变成了改写模式,只需要按下键盘的insert键即可

  5. MacPorts安装32位动态库

    http://superuser.com/questions/63198/install-32-bits-ports-on-snow-leopard

  6. 重写UILabler的sizeThatFits方法,需要触发两次才会有效果

    #import "ViewController.h" @interface SpecialLabel:UILabel @end @implementation SpecialLab ...

  7. IntelliJ IDEA 当pom.xml更新时,自动加载pom.xml

    http://stackoverflow.com/questions/19444471/intellij-idea-how-to-synchronize-project-libraries-with- ...

  8. centos 7.0 查看根目录下所有文件夹

    centos 7.0最小化安装 第一行是登录 [root@localhost ~]# [root@localhost ~]# cd ../ [root@localhost /]# ls bin dev ...

  9. iOS-马上着手开发iOS应用应用程序-第二部分构建应用程序

    第二部分构建应用程序 1,应用程序开发过程 2,设计用户界面 3,定义交互 4,教程:串联图 1,应用程序开发过程 定义概念 设计用户界面 定义交互 实现行为整合数据 对象是应用程序的基石 类是对象的 ...

  10. Yii2 行为

    // Step 1: 定义一个将绑定行为的类 class MyClass extends yii\base\Component { // 空的 } // Step 2: 定义一个行为类,他将绑定到My ...