当i相当大时,Fi也很大。现在不要求你求出Fi的值,只需要求出Fi的(十进制)位数。
//用通项公式,但是公式取对数时需要转换。
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n;
double a=1-sqrt(5.0),b=1+sqrt(5.0);
while(cin>>n&&n)
{
double ans=n*log10(b)+log10(1-pow(a/b,n*1.0))-n*log10(2.0)-log10(5.0)/2;
cout<<(int)(ans+1)<<endl;
}
return 0;
}
HUNNU OJ 10099
http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=10099
别人帮忙回答的: