1 条题解

  • 1
    @ 2022-8-13 21:05:36
    #include <iostream>
    using namespace std; 
    long long dp[25][25];
    int xx[9] = {0,1,1,2,2,-1,-1,-2,-2};
    int yy[9] = {0,-2,2,1,-1,2,-2,1,-1};
    bool b[25][25];
    int main(){
    	int x1,y1,x2,y2;
    	cin >> x1 >> y1 >> x2 >> y2;
    	for (int i = 0;i<=8;i++){
    		if (x2+xx[i] < 0 or y2+yy[i] < 0){
    			continue;
    		}
    		b[x2+xx[i]][y2+yy[i]] = true;
    		dp[x2+xx[i]][y2+yy[i]] = 0;
    	}
    	for (int i = 0;i<=x1;i++){
    		for (int j = 0;j<=y1;j++){
    			if (b[i][j] == true)
    				continue;
    			else if (i == 0 and j == 0)
    				dp[i][j] = 1;
    			else if (i == 0)
    				dp[i][j] = dp[i][j-1];
    			else if (j == 0)
    				dp[i][j] = dp[i-1][j];
    			else
    				dp[i][j] = dp[i-1][j] + dp[i][j-1];
    		}
    	}
    	cout << dp[x1][y1];
    	return 0;
    }
    
    • 1

    信息

    ID
    1742
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    259
    已通过
    62
    上传者