标签:
Description
Input
Output
Sample Input
Sample Output
#include <iostream> #include <cstdio> #include <cmath> using namespace std; int main() { int i,n,a[22],len; double s,d; a[0]=0;a[1]=1; for(i=2;i<22;i++) a[i]=a[i-1]+a[i-2]; while(scanf("%d",&n)!=EOF) { if(n<21) printf("%d\n",a[n]); else { s=log10(1.0/sqrt(5))+n*log10((1+sqrt(5))/2.0); len=(int)s; d=s+3-len; printf("%d\n",(int)pow(10,d)); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/chen9510/p/4734704.html