Advertisement
LEGEND2004

E - Grass

Sep 7th, 2023
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. /*#include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. const int N = 1e3 + 5;
  6. const int mod = 1e18 + 7;
  7. const int INF = 1e18;
  8. int dp[N];
  9.  
  10. signed main()
  11. {
  12.     int n , k;
  13.     cin >> n >> k;
  14.     dp[1] = 1;
  15.     int sum = 1;
  16.     for(int i = 2; i <= n; i++){
  17.         dp[i] = sum;
  18.         if((i - k) >= 0)
  19.             sum -= dp[i - k];
  20.         sum += dp[i];
  21.         sum += mod;
  22.         sum %= mod;
  23.     }
  24.     cout << dp[n] << endl;
  25. }*/
  26.  
  27. /*
  28. #include <bits/stdc++.h>
  29. using namespace std;
  30.  
  31. #define int long long
  32. const int N = 1e3 + 5;
  33. const int mod = 1e9 + 7;
  34. const int INF = 1e18;
  35. int dp[N];
  36.  
  37. signed main()
  38. {
  39.     int n , k;
  40.     cin >> n >> k;
  41.     dp[1] = 1;
  42.     for(int i = 2; i <= n; i++){
  43.         for(int j = (i - 1); j >= max(i - k , 0LL); j--){
  44.             dp[i] += dp[j];
  45.         }
  46.     }
  47.     cout << dp[n] << endl;
  48. }
  49. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement