题解 | #走方格的方案数#

走方格的方案数

http://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b

你以为是寻路?

其实就是选择。

答案 = alt

while (line = readline()) {
    let nums = line.split(" ");
    let col = +nums[0];
    let row = +nums[1];
    let num = col + row;
    let ans1 = 1;
    for (let i = 0; i < col; i++) {
        ans1 *= num;
        num--;
    }
    let ans2 = 1;
    for (let i = 1; i <= col; i++) {
        ans2 *= i;
    }
    let ans = ans1 / ans2;
    console.log(ans);
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务