Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "markettask.h"
- long long c[38][38];
- long long stepsToMarket(int n, int k)
- {
- if (n > k || n > 37 || n < 1 || k > 37 || k < 1)
- return -1;
- c[0][0] = 1;
- for (int i_k = 1; i_k < 38; ++i_k)
- {
- for (int j_n = 0; j_n < 38; ++j_n)
- {
- c[j_n][i_k] = ((j_n == 0) ? 0 : c[j_n - 1][i_k - 1]) +
- ((j_n == 37) ? 0 : c[j_n + 1][i_k - 1]);
- }
- }
- return c[n - 1][k - 1];
- }
Add Comment
Please, Sign In to add comment