poj3421

maksyuki 发表于 oj 分类,标签: ,
0

X-factor Chains

Given a positive integer X, an X-factor chain of length m is a sequence of integers, 1 = X0X1X2, …, Xm = satisfying Xi < Xi+1 and Xi | Xi+1 where a | b means a perfectly divides into b. Now we are interested in the maximum length of X-factor chains and the number of chains of such length.

Input

The input consists of several test cases. Each contains a positive integer X (X ≤ 220).

Output

For each test case, output the maximum length and the number of such X-factors chains.

Sample Input

2
3
4
10
100

Sample Output

1 1

1 1

2 1

2 2

4 6

Source

POJ Monthly--2007.10.06, ailyanlu@zsu

 

题目类型:整数素因子分解+组合计数

算法分析:为了得到最长的序列,除了头尾1和n之外,其他的约数应该按照递增排列且后一个约数要比前一个恰好多一个素因子,这样才能保证得到的序列是最长的。最长序列的数目是素因子幂和的可重排列(即素因子幂之和的阶乘/每个素因子幂的阶乘)