社区讨论

#3 #4 WA 求调

P1002[NOIP 2002 普及组] 过河卒参与者 2已保存回复 6

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
5 条
当前快照
1 份
快照标识符
@mdh15hz6
此快照首次捕获于
2025/07/24 14:47
8 个月前
此快照最后确认于
2025/07/24 17:49
8 个月前
查看原帖
CPP
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long v[22][22] = {};
	long long x, y;
	long long horse_x, horse_y;
	cin >> x >> y >> horse_x >> horse_y;
	for (long long i = 0; i < 20; i++) {
		for (long long j = 0; j < 20; j++) {
			if (
				(i == horse_x + 0 && j == horse_y + 0) ||
				(i == horse_x + 2 && j == horse_y + 1) ||
				(i == horse_x + 2 && j == horse_y - 1) ||
				(i == horse_x - 2 && j == horse_y + 1) ||
				(i == horse_x - 2 && j == horse_y - 1) ||
				(i == horse_x + 1 && j == horse_y + 2) ||
				(i == horse_x + 1 && j == horse_y - 2) ||
				(i == horse_x - 1 && j == horse_y + 2) ||
				(i == horse_x - 1 && j == horse_y - 2)
			){
				v[i][j] = 0;
			}
			else if (i == 0 || j == 0) {
				v[i][j] = 1;
			}
			else {
				v[i][j] = v[i - 1][j] + v[i][j - 1];
			}
		}
	}
	cout << v[x][y]<<endl;
	return 0;
}

回复

6 条回复,欢迎继续交流。

正在加载回复...