社区讨论
60分求调玄关
P1002[NOIP 2002 普及组] 过河卒参与者 2已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 6 条
- 当前快照
- 1 份
- 快照标识符
- @mhjqb04u
- 此快照首次捕获于
- 2025/11/04 06:45 4 个月前
- 此快照最后确认于
- 2025/11/04 06:45 4 个月前
rt
CPP#include<bits/stdc++.h>
using namespace std;
int n, m, x, y;
long long dp[30][30];
bool horse[30][30];
bool chack(int i, int j){
return i >= 0 && j >= 0 && i <= n && y <= m;
}
int main(){
cin>>n>>m>>x>>y;
if(chack(x, y)) horse[x][y] = true;
if(chack(x + 2, y + 1)) horse[x + 2][y + 1] = true;
if(chack(x + 2, y - 1)) horse[x + 2][y - 1] = true;
if(chack(x - 2, y + 1)) horse[x - 2][y + 1] = true;
if(chack(x - 2, y - 1)) horse[x - 2][y - 1] = true;
if(chack(x + 1, y + 2)) horse[x + 1][y + 2] = true;
if(chack(x + 1, y - 2)) horse[x + 1][y - 2] = true;
if(chack(x - 1, y + 2)) horse[x - 1][y + 2] = true;
if(chack(x - 1, y - 2)) horse[x - 1][y - 2] = true;
for(int i = 0;i <= n;i ++){
for(int j = 0;j <= m;j ++){
if(horse[i][j]){
dp[i][j] = 0;
continue;
}
if(i == 0 || j == 0){
dp[i][j] = 1;
continue;
}
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
}
}
cout<<dp[n][m];
}
回复
共 6 条回复,欢迎继续交流。
正在加载回复...