uva 10007 Count the Trees
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=948
卡特兰数*n!
- import java.math.BigInteger;
- import java.util.*;
- public class Main {
- public static void main(String[]args)
- {
- Scanner cin=new Scanner(System.in);
- BigInteger []a=new BigInteger[1000];
- a[0]=BigInteger.valueOf(1);
- for(int i=1; i<=300; i++)
- {
- int m=(4*i-2);
- a[i]=a[i-1].multiply(BigInteger.valueOf(m));
- a[i]=a[i].divide(BigInteger.valueOf(i+1));
- }
- int n;
- while(cin.hasNext())
- {
- n=cin.nextInt();
- if(n==0) break;
- BigInteger ans=BigInteger.valueOf(1);
- for(int i=1; i<=n; i++)
- {
- ans=ans.multiply(BigInteger.valueOf(i));
- }
- ans=ans.multiply(a[n]);
- System.out.println(ans);
- }
- }
- }
uva 10007 Count the Trees的更多相关文章
- UVa 10007 - Count the Trees(卡特兰数+阶乘+大数)
题目链接:UVa 10007 题意:统计n个节点的二叉树的个数 1个节点形成的二叉树的形状个数为:1 2个节点形成的二叉树的形状个数为:2 3个节点形成的二叉树的形状个数为:5 4个节点形成的二叉树的 ...
- Uva 10007 / HDU 1131 - Count the Trees (卡特兰数)
Count the Trees Another common social inability is known as ACM (Abnormally Compulsive Meditation) ...
- Count the Trees[HDU1131]
Count the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- zjuoj 3602 Count the Trees
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3602 Count the Trees Time Limit: 2 Seco ...
- uva 10712 - Count the Numbers(数位dp)
题目链接:uva 10712 - Count the Numbers 题目大意:给出n,a.b.问说在a到b之间有多少个n. 解题思路:数位dp.dp[i][j][x][y]表示第i位为j的时候.x是 ...
- UVa 10562 Undraw the Trees 看图写树
转载请注明: 仰望高端玩家的小清新 http://www.cnblogs.com/luruiyuan/ 题目大意: 题目传送门:UVa 10562Undraw the Trees 给定字符拼成的树,将 ...
- TZOJ 4292 Count the Trees(树hash)
描述 A binary tree is a tree data structure in which each node has at most two child nodes, usually di ...
- UVa 11408 - Count DePrimes
题目:一个数的素因子的和假设也是素数就叫做DePrimes,统计给定区间内的DePrimes. 分析:数论.本题使用用一种素数的筛法,欧拉筛法,也加线性筛法. 这样的方法,每次删选分两种情况:1.素因 ...
- UVA 10303 - How Many Trees?(数论 卡特兰数 高精度)
Problem D How Many Trees? Input: standard input Output: standard output Memory Limit: 32 MB A binary ...
随机推荐
- Java Socket 编程指南
Socket,又称为套接字,Socket是计算机网络通信的基本的技术之一.如今大多数基于网络的软件,如浏览器,即时通讯工具甚至是P2P下载都是基于Socket实现的.本文会介绍一下基于TCP/IP的S ...
- Ajax之 beforeSend和complete longind制作
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Consolas; min-height: 18.0px } p.p2 { margin: 0 ...
- java笔记14之private
private: 1 是一个权限修饰符 2 可以修饰成员变量和成员方法 被其修饰的成员只能在本类中被访问 class Demo { //int num = 1 ...
- Java多线程编程(二)
在 Java多线程编程(一) 中的多线程并没有返回值,本文将介绍带返回值的多线程. 要想有返回值,则需要实现新的接口Callable而不再是Runnable接口,实现的方法也改为call()方法,执行 ...
- 第1章 Python介绍
本章将包含Python的介绍,安装以及Python的数据类型及运算符.其中关于数据类型中的字符串.列表.元组和字典后续章节会着重介绍. 1.1 为什么学Python Python是一门简明并强大的面向 ...
- CComPtr用法
COM接口指针很危险,因为使用过程中需要每一个使用者都要严格并且正确的AddRef和Release,一旦出现问题,就会造成对象不能被正常释放,或者对象被重复删除,造成程序崩溃.所以使用COM接口,必须 ...
- Java 编程的动态性 第1 部分: 类和类装入--转载
原文地址:http://www.ibm.com/developerworks/cn/java/j-dyn0429/ 本文是这个新系列文章的第一篇,该系列文章将讨论我称之为 Java 编程的动态性的一系 ...
- RHEL7和RHEL6的主要变化
RHEL7和RHEL6的主要变化 RHEL7 RHEL6 文件系统 XFS EXT4 内核版本 3.10.x-x系列 2.6.x-x系列 内核名称 Maipo Santiago 发布时间 2014 ...
- LA 6449 IQ Test
[题目] 给出一个长度为n的数组(8<n<12),告诉你规律 (1<=d<=3)要求d尽量小 现在求第n+1项 [题解] 水题 不知道怎么求a1~ad? 用克拉默法则 [代码 ...
- Freemarker常用技巧(三)
freemarker模板解析过程 例如:一个freemarker表达式<body> ${hello} </body>,会被解析成三个部分,分别是<body>${he ...