# 代码

#include <bits/stdc++.h>
using namespace std;
enum{maxn = 1000006, Mod=1000000007};
int f[maxn];
int num[maxn];
int n;
int bsearch(int a)
{
int l =1, r = n;
while(l<=r)
{
int m = l+(r-l)/2;
if (f[m] == a)
return m;
if (f[m]  < a)
l = m+1;
else
r = m-1;
}
return 0;
}
int main()
{
//freopen("in.txt", "r", stdin);
memset(num, 0, sizeof(num));
f[1] = f[2] = 1;
for (int i=3; i<maxn; ++i)
f[i] = f[i-1] + f[i-2];
scanf("%d", &n);
for (int i=0; i< n; ++i)
{
int a;
scanf("%d", &a);
if (a==1)
{
num[2] = (num[2] + num[1]) %Mod;
num[1] = (num[1] +1)%Mod;
}
else
{
int p = bsearch(a);
if (p)
{
num[p] = (num[p] + num[p-1])%Mod;
}
}
}
int ret =0;
for (int i=1; i<maxn; ++i)
ret = (ret + num[i])%Mod;
printf("%d\n", ret);
return 0;
}


# 注意

1需要特殊考虑，因为fibonacci 中有两个1；

#### hihocoder 第113周 Fibonacci(动态规划)

2016-09-01 08:41:07

#### hiho一下 第113周 Fibonacci (dp)

2016-08-29 15:38:28

#### 113

2008-04-02 20:28:00

#### hiho~

2015-04-01 17:37:18

#### hiho Coder hiho字符串

2017-04-23 18:30:40

#### （113）UUID

2017-12-16 10:42:45

#### 113 字符串替换

2014-07-24 19:12:22

#### Leetcode 113

2017-09-23 13:47:07

#### 113 本地通知

2015-11-16 10:50:47

#### nyoj 113

2013-08-22 16:28:04