#3#4错误,求调!!(调必关)
查看原帖
#3#4错误,求调!!(调必关)
1632136
Fume_shroom楼主2025/7/26 07:45

60分,用递推做的```cpp

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long arr[114][114]={0};
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    arr[x][y]=1;
    arr[x+1][y+2]=1;
    arr[x+2][y+1]=1;
    arr[x+1][y-2]=1;
    arr[x+2][y-1]=1;
    arr[x-1][y+2]=1;
    arr[x-2][y+1]=1;
    arr[x-1][y-2]=1;
    arr[x-2][y-1]=1;
    if(arr[0][0]==1){
        cout<<0;
        return 0;
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(arr[i][j]==1){
                arr[i][j]=0;
                continue;
            }
            if(i==0||j==0){
                arr[i][j]=1;
            }
            else{
                arr[i][j]=arr[i][j-1]+arr[i-1][j];
            }
        }
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++) cout<<arr[i][j]<<" ";
        cout<<endl;
    }
    cout<<arr[n][m];
}
2025/7/26 07:45
加载中...