Count the possible plans for nurses
You can solve this problem with dynamic programming. Your states are
dp[day_number][worked_sofar]. here is a recursive implementation:
#include&lt;bits/stdc++.h&gt;

using namespace std;

vector&lt;vector&lt;int&gt; &gt; dp;
int n, k1, k2;
int solve(int day, int sofar){
    if(day &gt; n || sofar &gt; k2)return 1;
    if(dp[day][sofar] != -1)return dp[day][sofar];
    int ans = solve(day + 1, sofar + 1);
    if(sofar &gt;= k1)ans += solve(day + 1, 0);
    return dp[day][sofar] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin &gt;&gt; n &gt;&gt; k1 &gt;&gt; k2;
    dp.assign(n + 1, vector&lt;int&gt;(k2 + 1, -1));
    cout&lt;&lt;solve(1, 0);
    return 0;
}

```