P1002巨佬求调!debug了一下没啥问题,不知道为啥只能40分?
#include <iostream>
#include <cmath>
using namespace std;
const int ERR = -1;
int a[2000][2000];
int main()
{
int x, y, ma_x, ma_y;
cin >> x >> y >> ma_x >> ma_y;
for (int i = 0; i <= x; i++)
{
for (int j = 0; j <= y; j++)
{
if (i == 0) a[i][j] = 1;
else if (j == 0) a[i][j] = 1;
else if (i == ma_x && j == ma_y) a[i][j] = 0;
else if (abs(i - ma_x) == 2 && abs(j - ma_y) == 1) a[i][j] = 0;
else if (abs(i - ma_x) == 1 && abs(j - ma_y) == 2) a[i][j] = 0;
else a[i][j] = ERR;
}
}
for (int i = 1; i <= x; i++)
{
for (int j = 1; j <= y; j++)
{
if (a[i][j] == ERR) a[i][j] = a[i - 1][j] + a[i][j - 1];
// cout << i << j << ": " << a[i][j] << " ";
}
// cout << endl;
}
cout << a[x][y];
}