题解 | 牛牛的排列数

牛牛的排列数

https://www.nowcoder.com/practice/9ca1c236cdbf46da9e08e1f510808625

问一下大佬,为什莫要加if(n<m),这个判断条件
#include <stdio.h>
long long Reage(int x)//实现阶乘
{
    if(x==1)
    return 1;

    return Reage( x-1)*x ;
}
int main()
{
    int n=0;
    int m=0;

    scanf("%d%d",&n,&m);
    if(n>m)
    {
    int ret=(Reage(n)/Reage( n-m));
    printf("%d",ret);
    }
    else {
    printf("0");
    }
}
我用的是阶乘相处,给他拆开了,
排列数的递归公式,递归前几项没找到所以拆开了

全部评论

相关推荐

ohs的小木屋:比不少实习待遇高了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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