给出一个长度为n的序列A(A1,A2…AN)。如果序列A不是非降的,你必须从中删去一个数,
这一操作,直到A非降为止。求有多少种不同的操作方案,答案模10^9+7。
对于这个题目,我们用 f [ i , j ]表示选到 i ,i 必须选,已经删了j个,构成一个不降的子序列的方案数
于是由于每次都是从前for,然后统计个数,我们考虑用树状数组优化
因为取出来有一定的顺序,所以要乘以 ( n - i ) !
最后因为可能在去i+1的时候就已经不降了,所以我们需要容斥一下
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define re register
#define gc getchar()
#define ll long long
inline int read()
{
re int x(0); re char ch(gc);
while(ch>'9'||ch<'0') ch=gc;
while(ch>='0'&&ch<='9') x=(x*10)+(ch^48),ch=gc;
return x;
}
const int N=2200,mod=1e9+7;
int a[N]