标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4267 Accepted Submission(s):
1974
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 using namespace std; 6 int d[40]={0,1}; 7 int main() 8 { 9 int i,j; 10 for(i=2;i<=20;i++) 11 d[i]=d[i-1]+d[i-2]; 12 int n,ans; 13 double p,f; 14 f=(1.0+sqrt(5.0))/2.0; 15 while(~scanf("%d",&n)) 16 { 17 if(n<21) 18 { 19 printf("%d\n",d[n]); 20 continue; 21 } 22 p=-0.5*log10(5.0)+n*1.0*log(f)/log(10.0); 23 p=p-(int)p; 24 p=pow(10.0,p); 25 while(p<1000) 26 p*=10; 27 printf("%d\n",(int)p); 28 } 29 return 0; 30 }
标签:
原文地址:http://www.cnblogs.com/pshw/p/5163725.html