求调
查看原帖
求调
847562
tyy_2012楼主2023/11/7 13:43
#include<bits/stdc++.h>
using namespace std;
long long pic[10000][10000]={0},hor[2],went[2],gs=0,there[2]={0};
void xh(){
	for(int s1=0;s1<2;s1++){
		if(s1==0) there[0]++;
		else there[1]++;
		if(there[0]==went[0]&&there[1]==went[1]) gs++;
		else if(pic[there[0]][there[1]]!=2&&there[0]<=went[0]&&there[1]<=went[1])
			xh();
		if(s1==0) there[0]--;
		else there[1]--;
	}
}
int main(){
	cin>>went[0]>>went[1]>>hor[0]>>hor[1];
	pic[hor[0]][hor[1]]=2;
	pic[hor[0]-1][hor[1]+2]=2;pic[hor[0]-1][hor[1]-2]=2;
	pic[hor[0]+1][hor[1]+2]=2;pic[hor[0]+1][hor[1]-2]=2;
	pic[hor[0]+2][hor[1]-1]=2;pic[hor[0]-2][hor[1]-1]=2; 
	pic[hor[0]+2][hor[1]+1]=2;pic[hor[0]-2][hor[1]+1]=2; 
	for(int s1=0;s1<2;s1++){
		if(s1==0) there[0]++;
		else there[1]++;
		if(there[0]==went[0]&&there[1]==went[1]) gs++;
		else if(pic[there[0]][there[1]]!=2&&there[0]<=went[0]&&there[1]<=went[1])
			xh();
		if(s1==0) there[0]--;
		else there[1]--;
	}
	cout<<gs;
	return 0;
}

谢谢QAQ

2023/11/7 13:43
加载中...