首页 > 其他 > 详细

P1002 过河卒

时间:2020-08-30 19:35:16      阅读:65      评论:0      收藏:0      [点我收藏+]

注意将坐标整体偏移从(1,1)开始

#include<iostream>
using namespace std;
const int N=25;
typedef long long LL;
typedef pair<int,int> PII;
LL f[N][N];
int dx[]={0,-2,-1,1,2,2,1,-1,-2};
int dy[]={0,1,2,2,1,-1,-2,-2,-1};
bool vis[N][N];
PII b,m;

int main()
{
	cin>>b.first>>b.second;
	b.first++,b.second++;
	cin>>m.first>>m.second;
	m.first++,m.second++;
	
	
	for(int i=0;i<9;i++)
	{
		int a=m.first+dx[i],b=m.second+dy[i];
		vis[a][b]=1;
	}
	
	f[1][1]=1;
	for(int i=1;i<=b.first;i++)
		for(int j=1;j<=b.second;j++)
		{
			if(vis[i][j]) continue;
			f[i][j]=max(f[i][j],f[i-1][j]+f[i][j-1]);
		}
		
	cout<<f[b.first][b.second]<<endl;
		
}

P1002 过河卒

原文:https://www.cnblogs.com/fxh0707/p/13585995.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!