Little_hobbit

Магазин - Динамика

Jun 17th, 2020 (edited)
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include "markettask.h"
  2.  
  3. long long c[38][38];
  4.  
  5. long long stepsToMarket(int n, int k)
  6. {
  7.     if (n > k || n > 37 || n < 1 || k > 37 || k < 1)
  8.         return -1;
  9.  
  10.     c[0][0] = 1;
  11.     for (int i_k = 1; i_k < 38; ++i_k)
  12.     {
  13.         for (int j_n = 0; j_n < 38; ++j_n)
  14.         {
  15.             c[j_n][i_k] = ((j_n == 0) ? 0 : c[j_n - 1][i_k - 1]) +
  16.                           ((j_n == 37) ? 0 : c[j_n + 1][i_k - 1]);
  17.         }
  18.     }
  19.  
  20.     return c[n - 1][k - 1];
  21. }
  22.  
Add Comment
Please, Sign In to add comment