题目链接:http://noi.openjudge.cn/ch0206/1944/

题解:
  递推,题目中给出了很详细的过程,不讲解

 1 #include<cstdio>
 2 int n;
 3 int work(int x)
 4 {
 5     if(x==1)return 1;
 6     if(x==2)return 2;
 7     return work(x-1)+work(x-2);
 8 }
 9 int main()
10 {
11     scanf("%d",&n);
12     printf("%d",work(n));
13     return 0;
14 }

  其实我还爱着打表~

1 #include<cstdio>
2 int f[]={0,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946};
3 int main()
4 {
5     int n;
6     scanf("%d",&n);
7     printf("%d",f[n]);
8     return 0;
9 }

 

相关文章:

  • 2022-02-13
  • 2021-10-13
  • 2022-02-02
  • 2021-08-23
  • 2021-09-08
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-09
  • 2021-06-05
  • 2022-02-05
  • 2021-10-07
  • 2021-08-01
  • 2021-08-16
  • 2021-09-23
相关资源
相似解决方案