f[0] = f[1] = 1 ; f[i] = i * f[i-1] * f[i-2] ;求f[n]的因子个数。
以后看到这种f[n] = ...f[i-1] ... f[i-2]的类似表达式,一般还是联想到fibonacci比较靠谱。
正解也就是fibonacci。
f[2] = 2 ;
f[3] = 2 * 3 ;
f[4] = 2 * 2 * 3 * 4 ;
f[5] = 2 * 2 * 2 * 3 * 3 * 4 * 5
f[6] = 2 * 2 * 2 * 2 * 2 * 3 * 3 * 3 * 4 * 4 * 5
每个因子的个数是1,2,3,5,8...这样增加的,直接用fibonacci就可以算出每个因子出现了多少次。
因为要求因子个数,所以合数要算成质因数的多少次幂。
这个在求prime的时候随便处理一下就可以了。。。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <cctype>
using namespace std;
const int M=1000000007;
bool p[1000002];
__int64 c[1000002];
__int64 f[1000002];
int main()
{
__int64 n,i,j,k,l;
__int64 ans;
while(~scanf("%I64d",&n))
{
f[1]=f[2]=1;
for(i=3; i<=n; i++)
f[i]=(f[i-1]+f[i-2])%M;
for(i=2; i<=n; i++)
{
if(p[i])continue;
c[i]=f[n-i+1];
j=i+i;
while(j<=n)
{
p[j]=true;
k=j;
while(k%i==0)
{
k=k/i;
c[i]=(c[i]+f[n-j+1])%M;
}
j=j+i;
}
}
ans=1;
for(i=2; i<=n; i++)
ans=(ans*(c[i]+1))%M;
printf("%I64d\n",ans);
}
return 0;
}