Discription
Consider a sequence F i that satisfies the following conditions: 
Find the number of different divisors of F n.

Input

Input file contains the only integer number n (1 ≤ n ≤ 10 6).

Output

Output the answer modulo 10 9 + 7.

Example

Input:

3

Output:

4

考虑每个数的贡献,发现一个数i 有 f(n-i) 中途径乘到F(n)里,所以F(n) = Π i * f(n-i)。

至于再要求约数个数的话,我们只要再计算出每个质因子在最后这个大数中的次数就行了,一遍欧拉筛一遍统计就ojbk了。

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int maxn=1000000,ha=1000000007;
int zs[maxn/10],t=0,F[maxn+5];
int ans=1,C[maxn+5],n;
struct node{ int d,c;};
vector<node> g[maxn+5];
bool v[maxn+5];
inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline int ksm(int x,int y){ int an=1; for(;y;y>>=1,x=x*(ll)x%ha) if(y&1) an=an*(ll)x%ha; return an;} inline void solve(){
F[0]=F[1]=1;
for(int i=2;i<=n;i++) F[i]=add(F[i-1],F[i-2]); for(int i=2;i<=n;i++){
if(!v[i]) zs[++t]=i,g[i].pb((node){i,1});
for(int j=1,u;j<=t&&(u=zs[j]*i)<=n;j++){
v[u]=1;
if(!(i%zs[j])){
g[u]=g[i],g[u][0].c++;
break;
}
g[u].pb((node){zs[j],1});
for(int l=0,sz=g[i].size();l<sz;l++) g[u].pb(g[i][l]);
}
} for(int i=2,now;i<=n;i++){
now=F[n-i]; node x;
for(int j=g[i].size()-1;j>=0;j--){
x=g[i][j];
C[x.d]=add(C[x.d],x.c*(ll)now%ha);
}
} for(int i=2;i<=n;i++) if(C[i]) ans=ans*(ll)(C[i]+1)%ha;
} int main(){
scanf("%d",&n);
solve();
printf("%d\n",ans);
return 0;
}

  

URAL - 1860 Fiborial的更多相关文章

  1. POJ 1860(spfa)

    http://poj.org/problem?id=1860 题意:汇率转换,与之前的2240有点类似,不同的是那个题它去换钱的时候,是不需要手续费的,这个题是需要手续费的,这是个很大的不同. 思路: ...

  2. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  3. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  4. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  5. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  6. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

  7. ural 2068. Game of Nuts

    2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...

  8. ural 2067. Friends and Berries

    2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...

  9. ural 2066. Simple Expression

    2066. Simple Expression Time limit: 1.0 secondMemory limit: 64 MB You probably know that Alex is a v ...

随机推荐

  1. OpenCV中的图像形态学转换

    两个基本的形态学操作是腐蚀和膨胀.他们的变化构成了开运算,闭运算,梯度等.下面以这张图为例 1.腐蚀 这个操作会把前景物体的边界腐蚀掉. import cv2 import numpy as np i ...

  2. 实验4 —— [bx]和loop的使用

    实验 综合使用 loop.[bx],编写完整汇编程序,实现向内存 b800:07b8 开始的连续 16 个字单元重复填充字数据 0403H. 以下为示例程序: assume cs:code # 1 c ...

  3. win7下设置git客户端

    msysgit官网: http://msysgit.github.io/ 下载msysgit http://msysgit.googlecode.com/files/Git-1.8.5.2-previ ...

  4. debian 7 安装vagrant

    下载 vagrant_1.4.3_x86_64.deb: $ wget http://966b.http.dal05.cdn.softlayer.net/data-production/2f0b88e ...

  5. HDU 5514 Frogs 欧拉函数

    题意: 有\(m(1 \leq m \leq 10^9)\)个石子排成一圈,编号分别为\(0,1,2 \cdots m-1\). 现在在\(0\)号石头上有\(n(1 \leq n \leq 10^4 ...

  6. 20188472 https://www.cnblogs.com/chenzg90826/

    我是一名学计算机的大一学生,对学计算机比较感兴趣,但是对于计算机的了解程度还不够深,所以我在这方面还只是一个初学者.经过了一个学期对计算机和编程语言的学习,我觉得要真正的学好这门专业真的还要更努力.在 ...

  7. Java中String类通过new创建和直接赋值字符串的区别

    方式一:String a = “aaa” ; 方式二:String b = new String(“aaa”); 两种方式都能创建字符串对象,但方式一要比方式二更优. 因为字符串是保存在常量池中的,而 ...

  8. 再谈H2的MVStore与MVMap

    对H2的[MVStore]: http://www.cnblogs.com/simoncook/p/5188105.html 这篇文章的补充. 概述 我们通常用的map,比如HashMap Linke ...

  9. 使用phppgadmin 遇到的小问题

    无法登录,显示错误消息如下: Error:login disallowed for security reasons. 解决方法: 修改conf/config.inc.php文件中的extra_log ...

  10. 聊聊、Java Keytool P12 转 JKS

    最近公司合作机构需要更改服务证书,总共给了 3 个文件过来.openapi-cert.p12.openapi-cert.key.openapi-cert.crt. openapi-cert.crt - ...