SGU247(排列组合与大数运算)
2013-05-09 17:01
288 查看
题目:Difficult Choice
题目分析以及公式推导:
![](http://img.blog.csdn.net/20130509170103813)
题目分析以及公式推导:
import java.io.*; import java.util.*; import java.math.BigInteger; public class Solution { public static BigInteger fac[]=new BigInteger[2013]; public static void main(String[] args) { init(); Scanner cin = new Scanner(System.in); int t = cin.nextInt(); while(t--!=0) { int p=cin.nextInt(); BigInteger ans=fac[2*p]; BigInteger temp=fac[p]; ans=ans.divide(temp); ans=ans.divide(temp); ans=ans.subtract(BigInteger.valueOf(2)); ans=ans.divide(BigInteger.valueOf(p)); ans=ans.add(BigInteger.valueOf(2)); System.out.println(ans); } } public static void init() { for(int i=1;i<2012;i++) fac[i]=BigInteger.ONE; for(int i=2;i<2012;i++) fac[i]=fac[i-1].multiply(BigInteger.valueOf(i)); } }
相关文章推荐
- 高精度运算——大数阶乘、排列、组合
- hdu 1261 排列组合&&大数除法
- 阶乘、排列,组合的高精度运算
- 玲珑杯1029【大数分解质因子+排列组合】
- Python2.7基于笛卡尔积算法实现N个数组的排列组合运算示例
- JavaScript实现数学里的排列组合的A和C运算
- hdu4927 Series 1(组合+公式 Java大数高精度运算)
- hdu4927 Series 1(组合+公式 Java大数高精度运算)
- vijos - P1060盒子 (排列组合 + 大数 + python)
- 大数运算(3)——大数减法
- 玩玩递归1--Fib,排列,与组合
- HDU1133_50元跟100元去买票_catalan_大数运算
- Python实现的简单排列组合算法示例
- codeforce 128C Games with Rectangle 排列组合
- 动态规划与排列组合
- 小项目--大数运算
- hdu 4704 Sum【组合数学/费马小定理/大数取模】By cellur925
- Java中的排列组合(二)
- 【组合+错排】BZOJ4517(Sdoi2016)[排列计数]题解
- HDU 4372 Count the Buildings(组合数学-斯特林数,组合数学-排列组合)