ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1225. Flags

Time exceeded with C++.. I used recursion
Posted by Evans Owamoyo 3 Nov 2019 14:55
#include <bits/stdc++.h>
using namespace std;
int fibonacci(int v) {
    if (v == 0) {
        return 0;
    }
    if (v == 1) {
        return 1;
    }
    return fibonacci(v - 1) + fibonacci(v - 2);
}

int main() {
    int n; cin >> n;
    cout << 2 * fibonacci(n);
}
Re: Time exceeded with C++.. I used recursion
Posted by Evans Owamoyo 3 Nov 2019 15:21
Solved.. I should not have used recursion