POJ 2084 Game of Connections 卡特兰数+JAVA -
来源:互联网 发布:mysql触发器的作用 编辑:程序博客网 时间:2024/04/29 16:59
题目地址:http://poj.org/problem?id=2084
递推地方法:
假设有n对点,答案为f(n)
假设第一个点连接了第2*k+1个点,那么此时答案为f(k)*f(n-k-1),左边k对点和右边n-k-1对点
利用加法原理,n对点,一共有∑f(k)*f(n-k-1) {k>=0&&k<n}
也就是卡特兰数
利用BigInteger就好了
import java.util.*;import java.math.*;import java.text.*;import java.io.*;public class Main{public static void main(String[] args) {Scanner cin = new Scanner(new BufferedInputStream(System.in));BigInteger[] d = new BigInteger[100+5];d[0] = BigInteger.ONE;d[1] = BigInteger.ONE;d[2] = BigInteger.valueOf(2);for(int i=3;i<=100;i++){BigInteger temp=BigInteger.ZERO;for(int k=0;k<=i-1;k++) temp=temp.add(d[k].multiply(d[i-k-1]));d[i]=temp;}while(cin.hasNext()){int n=cin.nextInt();if(n==-1) break;System.out.println(d[n]);}}}
0 0
- POJ 2084 Game of Connections(卡特兰数,JAVA)
- POJ 2084 Game of Connections 卡特兰数+JAVA -
- POJ Game of Connections 卡特兰数
- POJ 2084 Game of Connections 卡特兰数
- 卡特兰数:poj 2084 Game of Connections+hdu 1023
- Poj 2084 Game of Connections(高精度卡特兰数)
- POJ 2084:Game of Connections 大数+卡特兰数
- poj 2084 Game of Connections (卡特兰数,大数乘除)
- POJ 2084 Game of Connections 递推/卡特兰数
- poj 2084 Game of Connections (卡特兰数、大数)
- POJ 2084 Game of Connections(大数+卡特兰数)
- Game of Connections 卡特兰数
- Game of Connections(卡特兰数)
- (组合数学3.1.2.2)POJ 2084 Game of Connections(卡特兰数公示的实现)
- 20140714 「初等数论 - 卡特兰数」 POJ 2084 Game of Connections
- POJ 2084 Game of Connections (思路+卡特兰数+大数处理)
- hdu 1134 Game of Connections(卡特兰数)
- HDU 1134 Game of Connections 高精度卡特兰数
- android studio 项目转为ecplise项目
- Android ActionBar Tab的宽度
- 定时图
- 求IOS录屏并录声音的方案
- 融云即时通讯
- POJ 2084 Game of Connections 卡特兰数+JAVA -
- Linux 重定向
- 数据结构(十五) 线索二叉树讲解(带头节点中序加线索) 以及实现的完整代码
- Android之FileExplore
- MySql使用
- Android 软键盘 禁用回车功能或者换成搜索功能
- <数据结构>二叉树的实现
- Android 传值出现空格 求各位大牛们帮帮忙解决一下
- 我的2016——时间战场