SHARE
TWEET

Untitled

a guest Aug 25th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3. #include <math.h>
  4. #include <vector>
  5. #include <set>
  6. #include <unordered_set>
  7. #include <tuple>
  8. #include <map>
  9. #include <unordered_map>
  10. #include <string>
  11. #include <string.h>
  12. #include <utility>
  13. #include <algorithm>
  14. #include <queue>
  15. #include <deque>
  16. #include <iterator>
  17. #include <stdlib.h>
  18. #include <cstdlib>
  19. #include <bitset>
  20. #include <fstream>
  21. #include <iomanip>
  22. // #pragma GCC optimize("Ofast,no-stack-protector")
  23. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  24. // #pragma GCC optimize("unroll-loops")
  25. // #pragma GCC optimize("fast-math")
  26. // #pragma GCC optimize("vpt")
  27. // #pragma GCC optimize("rename-registers")
  28. // #pragma GCC optimize("move-loop-invariants")
  29. // #pragma GCC optimize("unswitch-loops")
  30. // #pragma GCC optimize("branch-target-load-optimize")
  31. // #pragma GCC optimize("branch-target-load-optimize2")
  32. // #pragma GCC optimize("btr-bb-exclusive")
  33.  
  34. typedef long long ll;
  35. typedef long double ld;
  36. #define all(x) x.begin(), x.end()
  37.  
  38. using namespace std;
  39.  
  40. int main() {
  41.     int n = 0, k = 0; cin >> n >> k;
  42.     vector<vector<ll>> dp(k + 2, vector<ll> (n + 2, 0));
  43.     for (int i = 1; i <= n; ++i) {
  44.         dp[1][i] = 1;
  45.     }
  46.     for (int i = 2; i <= k; ++i) {
  47.         for (int j = 2; j <= n; ++j) {
  48.             for (int q = 0; q <= j - 2; ++q) {
  49.                 dp[i][j] += dp[i - 1][q] * (j - q - 1);
  50.             }
  51.         }
  52.     }
  53.     cout << dp[k][n];
  54. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top