题解 | #走方格的方案数#
走方格的方案数
https://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function () {
// Write your code here
function move(m, n){
//基线条件
if(m == 0 || n == 0){
return 1;
}else{
//递归条件
return move(m - 1, n) + move(m, n - 1);
}
}
while(line = await readline()){
let tokens = line.split(' ');
let a = parseInt(tokens[0]);
let b = parseInt(tokens[1]);
console.log(move(a, b));
}
}()
查看8道真题和解析