当前位置: 代码迷 >> 综合 >> AcWing 822. 走方格
  详细解决方案

AcWing 822. 走方格

热度:79   发布时间:2023-11-22 13:34:30.0

文章目录

  • AcWing 822. 走方格
  • AC代码


AcWing 822. 走方格

本题链接:AcWing 822. 走方格

本博客给出本题截图
在这里插入图片描述

AC代码

代码

#include <iostream>using namespace std;int n, m;
int ans;void dfs(int x, int y)
{
    if (x == n && y == m) ans ++ ;else{
    if (y < m) dfs(x, y + 1);if (x < n) dfs(x + 1, y);}
}int main()
{
    cin >> n >> m;dfs(0, 0);cout << ans << endl;return 0;
}