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

走方格的方案数

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

#include <stdio.h>
#include <string.h>

//一共走了m+n步 向下n,向右m
int fact(int n);
int main()
{

    int m, n;
    while (scanf("%d %d", &m, &n) != EOF)
    {
        int pathcount = 0;
        pathcount = fact(m + n) / (fact(m) * fact(n));
        printf("%d\n", pathcount);
    }

    return 0;
}

int fact(int n)
{
    int ret = 1;
    while (n >= 1)
    {
        ret *= n;
        n--;
    }
    return ret;
}
全部评论

相关推荐

牛客41406533...:回答他在课上学,一辈子待在学校的老教授用三十年前的祖传PPT一字一句的讲解,使用谭浩强红皮书作为教材在devc++里面敲出a+++++a的瞬间爆出114514个编译错误来学这样才显得专业
点赞 评论 收藏
分享
Java面试先知:我也是和你一样的情况,hr 说等开奖就行了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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