排列计数
排列计数
题解
本题是一道数论题,经题目分析,序列数应为 ,cp为错排数。
源码
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<queue>
#define MAXN 1000005
using namespace std;
typedef long long LL;
const LL mo=1e9+7;
LL n,m,a[MAXN],cp[MAXN];
LL jc[MAXN],invjc[MAXN];
#define gc() getchar()
template<typename _T>
inline void read(_T &x)
{
_T f=1;x=0;char s=gc();
while(s>'9'||s<'0'){if(s=='-')f=-1;s=gc();}
while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=gc();}
x*=

浙公网安备 33010602011771号