标签:strong pac 没有 组合数学 cst 固定 基本 递归 百度
题目描述:
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int xf(int x)
{
if(x==1)return 0;
if(x==2)return 1;
return (x-1)*(xf(x-1)+xf(x-2));
}
int main()
{
int n;
scanf("%d",&n);
cout<<xf(n);
return 0;
}
此类问题为配对问题,还可以这样问n个战士有自己固定的枪,问没有一个人拿对自己枪的情况;
接下来进行一下扩展:
错排公式:
标签:strong pac 没有 组合数学 cst 固定 基本 递归 百度
原文地址:http://www.cnblogs.com/zzyh/p/6601847.html