Untitled

 avatar
unknown
c_cpp
6 months ago
358 B
4
Indexable
#include <iostream>
using namespace std;

int countWays(int S, int E) {
    if (S == E) {
        return 1;
    }
    if (S > E) {
        return 0;
    }

    return countWays(S + 1, E) + countWays(S + 2, E) + countWays(S + 3, E);
}

int main() {
    int S, E;
    cin >> S >> E;

    cout << countWays(S, E) << endl;

    return 0;
}
Editor is loading...
Leave a Comment