Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int x, y;
  8. cin >> x >> y;
  9. vector<vector<int>> dp(9 - y, vector<int>(8));
  10. if (y == 8)
  11. {
  12. cout << '1';
  13. }
  14. else
  15. {
  16. for (int j = 0; j < 8; ++j)
  17. {
  18. dp[y - 1][j] = 0;
  19. }
  20. dp[y - 1][x - 1] = 1;
  21. for (int i = y; i < 8; ++i)
  22. {
  23. for (int j = 0; j < 8; ++j)
  24. {
  25. if (j = 0)
  26. {
  27. dp[i][j] = dp[i - 1][j + 1];
  28. }
  29. else if (j = 7)
  30. {
  31. dp[i][j] = dp[i - 1][j - 1];
  32. }
  33. else
  34. {
  35. dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j + 1];
  36. }
  37. }
  38. }
  39. int sum = 0;
  40. for (int i = 0; i < 8; ++i)
  41. {
  42. sum += dp[7][i];
  43. }
  44. cout << sum;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement