n个小朋友排排坐,只有一个人坐对,其他人都坐错的情况有多少种?

n个小朋友排排坐,只有一个人坐对,其他人都坐错的情况有多少种?
 
#include <iostream>
using namespace std;
int nums[66];
int func(int n)
{
    nums[2] = 1;
    for (int i = 3; i <= n; i++)
    {
        nums[i] = (i - 1) * (nums[i-1] + nums[i-2]);
    }
    return nums[n];
}
int main()
{
    int n;
    cin >> n;
    cout << n*func(n-1) << endl;
 system("pause");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/suyi-course-of-study/p/11404815.html
今日推荐