蓝桥杯 algo122 未名湖的烦恼 递归
#include <iostream> using namespace std; int m, n, ans; void solve(int m, int n, int cnt) { if (m == 0 && n == 0) { ans++; return; } if (cnt > 0 && n > 0) solve(m, n-1, cnt-1); if (m > 0) solve(m-1, n, cnt+1); } int main(int argc, char const *argv[]) { cin >> m >> n; solve(m, n, 0); cout << ans; return 0; }