求助
查看原帖
求助
220824
yyz1005楼主2021/1/15 23:10
#include<iostream>
using namespace std;
int main(){
	int fx,fy,hx,hy;
	cin >> fx >> fy >> hx>>hy;
	int board[fx+5][fy+5] = {0};
	//兵:0,0
	board[hx+2][hy-1] = -1;
	board[hx+1][hy+2] = -1;
	board[hx+1][hy-2] = -1;
	board[hx-2][hy+1] = -1;
	board[hx-2][hy-1] = -1;
	board[hx-1][hy+2] = -1;
	board[hx-1][hy-2] = -1;
	board[hx][hy] = -1;
	if(board[fx][fy] == -1){
		cout <<"0" << endl;
		return 0;
	}
	board[0][0] = 1;
	for(int i = 0; i <= fx; i++) {
	
		for(int j = 0; j <= fy; j++){
			if(board[i][j] != -1){
				int node1 = 0,node2 = 0,node3 = 0;
				if(i>0&&j>0)node1 = board[i-1][j-1];
				if(i>0)node2 = board[i-1][j];
				if(j>0)node3=board[i][j-1];
				if(node1 == -1) node1++;
				if(node2 == -1) node2++;
				if(node3 == -1) node3++;
				board[i][j]+=node1+node2+node3;
			}
			//cout << board[i][j] << " ";
		} 
		//cout << endl;
	}
	cout << board[fx][fy];
	return 0;
}
2021/1/15 23:10
加载中...