Advertisement
welleyth

4051. Grasshopper

Dec 27th, 2020
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define mp make_pair
  7. #define pb push_back
  8.  
  9. const int N = 100;
  10.  
  11. int dp[N];
  12.  
  13. signed main()
  14. {
  15.     ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  16.     //freopen("input.txt","r",stdin);
  17.     //freopen("output.txt","w",stdout);
  18.  
  19.     int n,k;
  20.     cin >> n >> k;
  21.  
  22.     dp[k+1] = 1;
  23.  
  24.     for(int i=k+1;i<=n+k;i++)
  25.     {
  26.         for(int j=i-1;j>=i-k;j--)
  27.         {
  28.             dp[i] += dp[j];
  29.         }
  30.     }
  31.  
  32.     cout << dp[n+k];
  33.  
  34.     return 0;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement