#在线求助! 1wa, 34TLE!
查看原帖
#在线求助! 1wa, 34TLE!
767465
xiayunpeng楼主2023/3/30 20:47
#include<bits/stdc++.h>
using namespace std;
long long n, m, p, q,a[25][25];
long long hx[8]={1,1,-1,-1,2,2,-2,-2},hy[8]={2,-2,2,-2,1,-1,1,-1};
long long f(long long x,long long y) {
	if(x==1||y==1)return 1;
	else if(a[x][y]==-1)return 0;
	return f(x-1,y)+f(x,y-1);
}
int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m >> p >> q;
	n++,m++,p++,q++;
	for (int i = 0; i < 8; i++) {
		int x=p+hx[i], y=q+hy[i];
		if(x<=n&&x>0&&y<=m&&y>0) a[x][y]=-1;
	}
	a[p][q]=-1;
	return cout << f(n,m),0;
}
2023/3/30 20:47
加载中...