AcWing 822. 走方格 - Java
原题链接
困难
作者:
KYCygni
,
2021-03-29 10:41:39
,
所有人可见
,
阅读 191
Java 代码
import java.util.Scanner;
public class Main
{
public static int row = 0;
public static int col = 0;
public static int ans = 0;
public static void dfs (int x, int y)
{
if (x == row && y == col)
ans += 1;
else
{
if (x < row)
dfs (x + 1, y);
if (y < col)
dfs (x, y + 1);
}
}
public static void main (String[] args)
{
Scanner cin = new Scanner(System.in);
row = cin.nextInt();
col = cin.nextInt();
dfs (0, 0);
System.out.println (ans);
}
}