#include
#include
using namespace std;
long f(long n)
{
long f1 = 1;
long f2 = 1;
long f3 = 0;
if (n == 1 || n == 2)
return 1;
for (long i = 2; i < n; i++)
{
f3 = (f1+f2)%1000000007;
f1 = f2%1000000007;
f2 = f3%1000000007;
}
return f3;
}
int main()
{
long n;
cin >> n;
long result = f(n);
cout << result << endl;
return 0;
}
由于输出的 f mod 10e9+7,数过大,结果mod会溢出,需要中途mod:(a+b)%c = a%c + b%c