社区讨论
为什么输出的是随机数?
P1002[NOIP 2002 普及组] 过河卒参与者 5已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @mhizpt3z
- 此快照首次捕获于
- 2025/11/03 18:21 4 个月前
- 此快照最后确认于
- 2025/11/03 18:21 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
int dx[] = {0, -2, -1, 1, 2, 2, 1, -1, -2};
int dy[] = {0, 1, 2, 2, 1, -1, -2, -2, -1};
int main(){
int bx,by,hx,hy;
cin >>bx>>by>>hx>>hy;
int a[25][25],b[25][25];
for(int i=1;i<=bx;i++){
for(int j=1;j<=by;j++){
a[i][j]=0;
}
}
for(int i=1;i<=bx;i++){
for(int j=1;j<=by;j++){
b[i][j]=0;
}
}
a[hx][hy]=1;
a[hx-1][hy-2]=1;
a[hx-2][hy-1]=1;
a[hx-2][hy+1]=1;
a[hx-1][hy+2]=1;
a[hx+1][hy-2]=1;
a[hx+2][hy-1]=1;
a[hx+2][hy+1]=1;
a[hx+1][hy+2]=1;
b[1][1]=1;
for(int i=1;i<=bx;i++){
for(int j=1;j<=by;j++){
if(i==1&&j==1){
continue;
}
if(a[i][j]==0){
b[i][j]=b[i-1][j]+b[i][j-1];
}
}
}
cout<<b[bx][by]<<endl;
return 0;
}
回复
共 5 条回复,欢迎继续交流。
正在加载回复...