分析
题目名称给予了很大的提示
如果打表的话,会发现从1~n的指数为fib[n-i+1]
然后把非质因数的指数贡献算到质因数那里,因子个数就等于所有质因子指数+1的乘积
#include <iostream> #include <cstdio> using namespace std; typedef long long ll; const int P=1e9+7; const int N=1e6+10; ll fib[N],ans[N]; int n; bool prime[N]; int main() { scanf("%d",&n); if (n==0||n==1) { printf("1"); return 0; } fib[n]=1;fib[n-1]=1; for (int i=n-2;i;i--) fib[i]=(fib[i+1]+fib[i+2])%P; for (int i=2;i<=n;i++) { if (prime[i]) continue; ans[i]=fib[i]; int cn=i*2; while (cn<=n) { prime[cn]=1; int x=cn; for (;x%i==0;x/=i) (ans[i]+=fib[cn])%=P; cn+=i; } } ll lans=1; for (int i=1;i<=n;i++) if (!prime[i]) (lans*=(ans[i]+1))%=P; printf("%lld",lans); }