Advertisement
STANAANDREY

stirling

Mar 11th, 2020
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, k;
  7.     cin >> n >> k;
  8.  
  9.     vector<vector<int>> stir(n + 1, vector<int>(k + 1));
  10.     stir[0][0] = 1;
  11.  
  12.     for (int i = 1; i <= n; i++)
  13.     {
  14.         for (int j = 1; j <= min(i, k); j++)
  15.             stir[i][j] = stir[i - 1][j - 1] + j * stir[i - 1][j];
  16.     }
  17.  
  18.     cout << stir[n][k] << '\n';
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement