个人答案:

 1 #include"iostream"
 2 #include"stdio.h"
 3 #include"string.h"
 4 using namespace std;
 5 typedef long long ll;
 6 const int MAXN=10000;
 7 
 8 ll fib[MAXN];
 9 ll Fibonacci(int n)
10 {
11     if(fib[n]!=-1)
12         return fib[n];
13     return fib[n]=Fibonacci(n-1)+Fibonacci(n-2);
14 }
15 
16 int main()
17 {
18     int n;
19     memset(fib,-1,sizeof(fib));
20     fib[0]=0;
21     fib[1]=1;
22     while(cin>>n)
23     {
24         cout<<Fibonacci(n)<<endl;
25     }
26     return 0;
27 }
View Code

相关文章:

  • 2021-05-16
  • 2021-04-10
  • 2021-06-04
  • 2021-10-06
  • 2021-07-20
猜你喜欢
  • 2022-01-26
  • 2021-10-01
  • 2022-02-12
  • 2022-01-15
  • 2022-12-23
  • 2021-09-25
相关资源
相似解决方案