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.73 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(8, 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. if (j == x - 1)
  19. {
  20. dp[y - 1][x - 1] = 1;
  21. }
  22. else
  23. {
  24. dp[y - 1][j] = 0;
  25. }
  26. }
  27. for (int i = y; i < 8; ++i)
  28. {
  29. for (int j = 0; j < 8; ++j)
  30. {
  31. if (j = 0)
  32. {
  33. dp[i][j] = dp[i - 1][j + 1];
  34. }
  35. else if (j = 7)
  36. {
  37. dp[i][j] = dp[i - 1][j - 1];
  38. }
  39. else
  40. {
  41. dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j + 1];
  42. }
  43. }
  44. }
  45. int sum = 0;
  46. for (int i = 0; i < 8; ++i)
  47. {
  48. sum += dp[7][i];
  49. }
  50. cout << sum;
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement