wa #3 #4,已开long long,求调
查看原帖
wa #3 #4,已开long long,求调
637410
sqrt404楼主2024/9/30 16:09
#include <bits/stdc++.h>
#define int long long
using namespace std;
int ax = 0, ay = 0, bx, by, cx, cy, dp[25][25];
bool IsHorse(int x, int y)
{
	return (cx - 1 == x && cy - 2 == y) ||
		   (cx - 2 == x && cy - 1 == y) ||
		   (cx - 2 == x && cy + 1 == y) ||
		   (cx - 1 == x && cy + 2 == y) ||
		   (cx + 1 == x && cy - 2 == y) ||
		   (cx + 2 == x && cy - 1 == y) ||
		   (cx + 2 == x && cy + 1 == y) ||
		   (cx + 1 == x && cy + 2 == y) || 
		   (cx == x && cy == y);
}
signed main()
{
	cin >> by >> bx >> cy >> cx;
	dp[0][0] = 1;
	for(int i = 1; i <= bx; i++) dp[i][0] = 1;
	for(int i = 1; i <= by; i++) dp[0][i] = 1;
	for(int i = 1; i <= bx; i++)
	{
		for(int j = 1; j <= by; j++)
		{
			if(IsHorse(i, j)) continue;
			else
			{
				dp[i][j] = dp[i - 1][j] * (!IsHorse(i - 1, j)) + dp[i][j - 1] * (!IsHorse(i, j - 1));
//				printf("%d %d %d\n", i, j, dp[i][j]); 
			}
		}
	}
//	for(int i = 0; i <= bx; i++)
//	{
//		for(int j = 0; j <= by; j++) printf("%d ", dp[i][j]); 
//		printf("\n");
//	}
	cout << dp[bx][by] << endl;
	return 0;
}
2024/9/30 16:09
加载中...