题解 | #牛群全排列数#
牛群全排列数
https://www.nowcoder.com/practice/5ab233c23fcc4c69b81bd5a66c07041c
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param n int整型
* @return int整型
*/
// 这样会越界
// int factorial(int n) {
// // write code here
// if(n==1)
// return 1;
// return n*factorial(n-1)%1000000007;
// }
long dfs(int n)
{
if(n==1)
return 1;
return n*dfs(n-1)%1000000007;
}
int factorial(int n) {
return dfs(n);
}
};
虚数五行区解题中心 文章被收录于专栏
非淡泊无以明志,非宁静无以致远



查看2道真题和解析