0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 18:28:47 +00:00

820. 递归求斐波那契数列

https://www.acwing.com/problem/content/submission/code_detail/14063990/
This commit is contained in:
Baoshuo Ren 2022-05-09 19:21:06 +08:00
parent 35ed69f23a
commit f385d08b6d
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

20
AcWing/820/820.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
int f(int x) {
return x == 1 || x == 2 ? 1 : f(x - 1) + f(x - 2);
}
int n;
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
cout << f(n) << endl;
return 0;
}