'commit'
This commit is contained in:
28
TangDou/LanQiaoBei/LanQiaoBeiWhitePaper/4_RobotDfs.cpp
Normal file
28
TangDou/LanQiaoBei/LanQiaoBeiWhitePaper/4_RobotDfs.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int m, n;
|
||||
|
||||
int dx[2] = {0, 1};
|
||||
int dy[2] = {1, 0};
|
||||
int cnt;
|
||||
|
||||
void dfs(int x, int y) {
|
||||
if (x == m && y == n) {
|
||||
cnt++;
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int tx = x + dx[i], ty = y + dy[i];
|
||||
if (tx <= m && ty <= n)
|
||||
dfs(tx, ty);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> m >> n;
|
||||
dfs(1, 1);
|
||||
printf("%d", cnt);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user