2 solutions

  • 4
    @ 2024-5-10 17:02:32

    #include using namespace std; int countWays(int n) { if (n <= 0) { return 0; } else if (n == 1) { return 1; } else if (n == 2) { return 2; } else { return countWays(n - 1) + countWays(n - 2); } } int main() { int n; while (cin >> n) { cout << countWays(n) << endl; } return 0; }

    Information

    ID
    105
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    7
    Tags
    (None)
    # Submissions
    238
    Accepted
    49
    Uploaded By