(zju3405)Counting Factor Trees
来源:互联网 发布:淘宝猛犸象牙 编辑:程序博客网 时间:2024/06/05 06:08
Counting Factor Trees
Time Limit: 2 Seconds Memory Limit: 65536 KB
Factoring, i.e., listing all the prime factors, of an integer is a useful skill that often helps to solve math problems. For example, one of the ways to find the GCD (Greatest Common Divisor) or LCM (Least Common Multiple) of two integers is by listing all their prime factors. The GCD is then the product of all the common factors; the LCM is the product of all the remaining ones.
The Factor Tree is a tool for finding such prime factorizations. The figure below demonstrates three factor trees of 108. At the beginning a root with a number is given, say N, which is to be factored. Then, the root is factored into two children N1 and N2 such that N = N1 × N2 (N1 ≥ 2, N2 ≥ 2). Note that N1 and N2 need not be prime. The same factoring process continues until all the leaves are prime.
While the prime factorization is unique, the factor tree reflects the order in which the factors were found, and is by no means unique. So, how many factor trees of a number are there?
Input
There are no more than 10000 cases. A line containing an integer N (2 ≤ N ≤ 1000000000) is given for each case.
Output
Print the number of factor trees of N in a line for each case. The answer will be fit in a signed 64-bit integer.
Sample Input
12108642485760
Sample Output
61409637611984000
Author: GAO, Yuan
Contest: ZOJ Monthly, September 2010
题意:给出一个数,然后统计其质因子组成的完全二叉树有多少种。
首先对于n个叶子的完全二叉树 其个数为卡塔兰数序列的第n-1个值(求卡塔兰数可用状态转移方程 dp[i] = sum(dp[j] * dp[i - 1 - j] | 0 <= j < i)).
然后对其质因子进行排列,C(sum,a) * C(sum - a.b) * C(sum - a - b,c) ……;
- (zju3405)Counting Factor Trees
- Counting Factor Trees zoj 3405
- zoj 4013 Counting Factor Trees
- ZOJ Problem Set - 3405 Counting Factor Trees
- HDOJ-3240 Counting Binary Trees(数论)
- uestc 1554 Counting Binary Trees (catalan 数)
- HDU3240-Counting Binary Trees(Catalan数+求逆元(非互质))
- HDU3240 Counting Binary Trees (卡特兰数,拓欧求逆元)
- HDU 3240 Counting Binary Trees
- 因子分析(Factor Analysis)
- 因子分析(Factor Analysis)
- 因子分析(Factor Analysis)
- 因子分析(Factor Analysis)
- 因子分析(Factor Analysis)
- Factor Analysis (1)
- Factor Analysis (2)
- The Factor(hdu5428)
- 因子分析(Factor Analysis)
- epoll机制
- on error resume next用法
- SAP中如何建立F4搜索帮助
- 数据库建立索引的原则
- 2011-6-18 0:55:20
- (zju3405)Counting Factor Trees
- DELPHI 对DICOM中的窗宽、窗位调整
- Windows Phone开发(一)-- 开发环境和结构
- [原创]sql like模式转换成等价的正则表达式的辅助类
- Adding a startup script to be run at bootup
- 虽有遗憾,不曾后悔——写在离校之前
- 苦战到深夜啊
- 环境win 7 + vs2010命名空间“System.Web.UI”中不存在类型或命名空间名称“ScriptManager”
- Coldfusion: customtag的一个用法之二。