救救孩子吧
查看原帖
救救孩子吧
230875
Surge_of_Force楼主2021/2/8 20:27
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
bool g[30][30];
long long map[30][30];
struct point{
	int x,y;
}; 
int main()
{
	point c,b;
	cin>>b.x>>b.y>>c.x>>c.y;
	map[0][0]=1;
	if(c.x>1 and c.y!=0)   g[c.x - 2][c.y - 1] = 1;
	if(c.x<19 and c.y!=0)  g[c.x + 2][c.y - 1] = 1;
	if(c.x>1 and c.y!=20)  g[c.x - 2][c.y + 1] = 1;
	if(c.x<19 and c.y!=20) g[c.x + 2][c.y + 1] = 1;
	if(c.x!=0 and c.y>1)   g[c.x - 1][c.y - 2] = 1;
	if(c.x!=0 and c.y<19)  g[c.x - 1][c.y + 2] = 1;
	if(c.x!=20 and c.y>1)  g[c.x + 1][c.y - 2] = 1;
	if(c.x!=20 and c.y<19) g[c.x + 1][c.y + 2] = 1;
	for(int i=0;i<=b.x;i++)
	    for(int j=0;j<=b.y;j++)
	    {
	    	if(g[i][j]==0&&i!=0&&j!=0)
	    	   map[i][j]=map[i-1][j]+map[i][j-1];
	    	if(g[i][j]==0&&i!=0&&j==0)
	    	   map[i][j]=map[i-1][j];
	    	if(g[i][j]==0&&i==0&&j!=0)
	    	   map[i][j]=map[i][j-1];
	    	
		}
	cout<<map[b.x][b.y];
	return 0;
}
2021/2/8 20:27
加载中...