Sets with a given Least Common Multiple
Problem 590
Let H(n) denote the number of sets of positive integers such that the least common multiple of the integers in the set equals n.
E.g.:
The integers in the following ten sets all have a least common multiple of 6:
{2,3}, {1,2,3}, {6}, {1,6}, {2,6} ,{1,2,6}, {3,6}, {1,3,6}, {2,3,6} and {1,2,3,6}.
Thus H(6)=10.
Let L(n) denote the least common multiple of the numbers 1 through n.
E.g. L(6) is the least common multiple of the numbers 1,2,3,4,5,6 and L(6) equals 60.
Let HL(n) denote H(L(n)).
You are given HL(4)=H(12)=44.
Find HL(50000). Give your answer modulo 109.
具有指定最小公倍数的集合
设 H(n)表示所有由最小公倍数为n的正整数组成的集合的个数.
例如:以下10个集合中的数的最小公倍数都是6。(并且没有其他集合符合这个条件)
{2,3}, {1,2,3}, {6}, {1,6}, {2,6} ,{1,2,6}, {3,6}, {1,3,6}, {2,3,6} , {1,2,3,6}.
因此H(6)=10。
设L(n) 表示从1~n的数的最小公倍数。
例如:L(6)是 1,2,3,4,5,6 的最小公倍数。因此L(6) = 10。
设HL(n) 表示 H(L(n))。
已知 HL(4)=H(12)=44。
求HL(50000)。给出答数除以 109的余数。
分析:
求H(n)的过程是,列出所有n的因数,假定不包含n本身有m个,那么,
1.如果集合中有n,这m个数都可以存在或不存在而不影响最小公倍数。所以有2^m个。
2.如果集合中没有n,必须从m个数中挑选出一些数,这些数的最小公倍数是n。
用上述方法来做H(12),因数有 1,2,3,4,6,12。包含12的集合有2^5=32个。不包含12的集合,必须同时包含2个因数,如果同时包含4和6,有2^3=8个。如果同时包含4和3(但不包含6),有2^2=4个。
再看1~n的数的最小公倍数。把每个数都写成p1^e1*p2^e2...pn^en形式(其中p是质数,e大于0),最小公倍数形式是p1^max(e1)*p2^max(e2)...pn^max(en),其中max表示它所在的质数在1~n某个数中最大的幂次.以1~8的数为例,其最小公倍数=2^3*3^1*5^1*7^1.
分解因数的程序
#include
#define NN 50000
static int p[NN+1]= {0};
int main()
{
for(int i=2; i<=NN; i++)
if(p[i]==0)
for(int j=i; j<=NN; j+=i)
{
if(p[j]==0)
p[j]=i;
}
for(int i=2; i<=NN; i++)
{
printf("%d:",i);
int k=i;
while( k>1)
{
int d=p[k];
printf(" %d",d);
k/=d;
}
printf("\n");
}
}
1~50000的最小公倍数L(50000)是:
215395675(11·13)4(17·...·31)3(37·...·223)2(227·...·49999) .
这个数的因数个数是16*10*7*6*52* .... 2,记作 C,
包含这个数的集合个数是2^(C-1).
不包含L(50000)的集合,必须至少包含2个数,它们包含L(50000)所有质因数的最高次幂,而且必须一个数就包含,而不能2个数合起来包含,比如,2的最高次是15,必须一个数就是2^15的倍数.