Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- typedef long long ll;
- const int maxn = 105;
- int n, m, k;
- ll dp[maxn][maxn];
- ll rec(int food, int rooms) {
- if(food == n and rooms == k) {
- return 1;
- }
- if(dp[food][rooms] != -1) {
- return dp[food][rooms];
- }
- ll res = 0;
- for(int i = 1; i <= m; i++) {
- if(food + i <= n) {
- res += rec(food + i, rooms + 1);
- }
- }
- dp[food][rooms] = res;
- return res;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- memset(dp, -1, sizeof dp);
- cin >> n >> k >> m;
- cout << rec(0, 0) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment