SHARE
TWEET

Untitled

a guest Feb 27th, 2020 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <string>
  5. #include <vector>
  6. #include <algorithm>
  7. #include <cmath>
  8. #include <math.h>
  9. #include <set>
  10. #include <map>
  11. #include <queue>
  12. #include <deque>
  13. #include <stack>
  14.  
  15.  
  16. #define f first
  17. #define s second
  18.  
  19. using namespace std;
  20.  
  21. long long a[100];
  22.  
  23. int main()
  24. {
  25.     ios_base::sync_with_stdio(false);
  26.     cin.tie(0);
  27.  
  28.     int n, k;
  29.     cin >> n >>  k;
  30.  
  31.     a[1] = 1;
  32.  
  33.     for (int i = 1; i <= n; i++)
  34.         for (int j = i - 1; j >= max(0, i - k); j--)
  35.             a[i] += a[j];
  36.  
  37.     //for (int i = 2; i <= n; i++)
  38. //      cout << a[i] << " ";
  39.  
  40. //  cout << endl;
  41.  
  42.     cout << a[n];
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top