跳到正文

个人记录

P1644 跳马问题( 样例没过 )

Joeger约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年4月18日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include <bits/stdc++.h>
using namespace std;
int n,m,a[100][100],
d[5][3]={{-1,-2},{-2,-1},{-2,1},{-1,2}};
int main()
{
	cin>>n>>m;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0 && j==0)
			{
				a[i][j]=1;
			}
			else
			{
				for(int k=0;k<4;k++)
				{
					int o=i+d[k][0],p=j+d[k][1];
					if(o<0 || o>n || p<0 || p>m)
					{
						continue;
					}
					else
					{
						a[i][j]+=a[o][p];
					}
				}
			}
		}
	}
	cout<<a[n][m];
	return 0;
}
原文