B.cpp 312 B

12345678910111213141516171819
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int f(int n) {
  4. if (n == 1 || n == 2) {
  5. return n;
  6. }
  7. else {
  8. return f(n - 1) + f(n - 2);
  9. }
  10. }
  11. int main() {
  12. int i, n, c;
  13. cin >> n;
  14. for (i = 1; i <= n; i++) {
  15. cin >> c;
  16. cout << f(c) << endl;
  17. }
  18. return 0;
  19. }