下面详解
http://hi.baidu.com/aekdycoin/item/a4407c37850e5b9db80c03a6
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double f = (sqrt(5.0)+1.0)/2.0;
int main()
{
int a[21]={0,1,1};
for(int i = 3; i <= 20; i++)
a[i] = a[i-1]+a[i-2];
int n;
while(cin >> n)
{
if(n<21)
{
cout << a[n] <<endl;
continue;
}
double bit = -0.5*log(5.0)/log(10.0)+((double)n)*log(f)/log(10.0);
bit = bit - floor(bit);
bit = pow(10.0, bit);
while(bit<1000)
{
bit =bit*10.0;
}
int m = bit;
cout << m <<endl;
}
}