60分,请大神求助
查看原帖
60分,请大神求助
369347
ZkjTCTC楼主2020/9/17 21:19
//
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n,m,HN,HM;
	cin >>n>>m>>HN>>HM;
	long long s[n+1][m+1];
	
	for ( int i = 0 ; i <= m ; i++ ){
		for ( int j = 0 ; j <= n ; j++ ){
			s[j][i]=-1;
		}
	}
	
	for ( int i = 0 ; i <= m ; i++ ){
		s[0][i]=1;
	}
	for ( int i = 1 ; i <= n ; i++ ){
		s[i][0]=1;
	}
	
	s[HN][HM]=0;
	if ( HN-1>=0 && HM-2>=0 )
		s[HN-1][HM-2]=0;
	if ( HN-2>=0 && HM-1>=0 )
		s[HN-2][HM-1]=0;
	if ( HN+1<=n && HM+2<=m )
		s[HN+1][HM+2]=0;
	if ( HN+2<=n && HM+1<=m )
		s[HN+2][HM+1]=0;
	if ( HN-1>=0 && HM+2<=m )
		s[HN-1][HM+2]=0;
	if ( HN-2>=0 && HM+1<=m )
		s[HN-2][HM+1]=0;
	if ( HN+1<=n && HM-2>=0 )
		s[HN+1][HM-2]=0;
	if ( HN+2<=n && HM-1>=0 )
		s[HN+2][HM-1]=0;
	
	for ( int i = 1 ; i <= m ; i++ ){
		for ( int j = 1 ; j <= n ; j++ ){
			if ( s[j][i]==-1 ){
				s[j][i]=s[j-1][i]+s[j][i-1];
			}
		}
	}
	cout <<s[n][m]<<endl;
	return 0;
}

输入:20 20 4 0
正确输出:56477364570
我的输出:57050531010

2020/9/17 21:19
加载中...