Title Description
G Department has a total of n students, m gate compulsory course. The number of these n classmates is 0 to N-1, where B is number No. 0. This m-gate compulsory number is a 0 to M-1 integer. The score that a classmate can get on a compulsory course is 1 to an integer in the UI.
If the achievement of a in each course is less than or equal to the result obtained by B, it is said that a is crushed by B. In the case of the B God, the G-system was crushed by him (excluding himself), while the other n-k-1 students were not crushed by him. D God found the B-God's rank for each compulsory course.
The ranking here refers to: if the B God a course ranking of R, it means that there are only R-1 students This course score is greater than the score of B God, there are only n-r students this course scores less than equal to B God (not including himself).
We need to find out the number of students who are required to score each course, so that they can satisfy both the B-God's claim and the D-found ranking. There are two different cases when and only if any of the students get a different score in any one course.
You don't need to be as powerful as D God, you just have to figure out the remainder of the 10^9+7.
Input Format:
The first line contains three positive integer n,m,k, each representing the number of students in the G series (including B-gods), the number of required courses and the number of students who have been crushed by B-God.
The second line contains m positive integers, which in turn represent the highest score UI for each course.
The third line contains m positive integers, which in turn represent the rank ri of the B gods in each course. Guaranteed 1<=ri<=n.
The data guarantees that at least 1 things make B God's word set.
output Format:
Only a single positive integer that represents the remainder of the modulo 10^9+7 that satisfies the condition.
\ (F[i][j] in I means processing to the first account, J indicates to the first account has J person by B God crush \)
\ (transfer condition is \)
\[f[i][j]=\sum_{k=j}^{n-1}{f[i-1][k]*c_{k}^{k-j}*c_{n-1-k}^{rank[i]-1-k+j}*\sum_{p=1}^{u_i}p^{n-rank[i]} (U_i-p ) ^{rank[i]-1}}\]
The understanding of the formula can be referred to https://www.luogu.org/blog/winxp/solution-p3270
Then \ ( g[i]=\sum_{p=1}^{u_i}p^{n-rank[i]} (u_i-p) ^{rank[i]-1}\) is about \ ( u_i\) the \ (n\) of the sub-type, The Lagrange interpolation method can be used to evaluate the value.
Implementation: Record the value of \ (G[i] (i\in,..., n) \) in each \ (rank[i]\) case, and then solve the value of \ (g[u_i]\) using Lagrange interpolation formula
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring>using namespace std;const int N=105;const int Mod=1e9+7;int read () {int X=0,ff=1;char ch=getchar (); while (!isdigit (CH)) {if (ch== '-') Ff=-1;ch=getchar ();} while (IsDigit (ch)) {x=x*10+ch-' 0 '; Ch=getchar ();} return X*FF;} int c[n][n];int f[n][n];int g[n];int n,m,k;int mx[n],rnk[n];void init () {c[0][0]=1; for (int i=1;i<n;i++) {//Do not equal N, explode array is wrong ... Adjusted for half a day qwq c[0][i]=1; for (int j=1;j<=i;j++) c[j][i]=1ll* (c[j-1][i-1]+c[j][i-1])%mod; }}int pow (int a,int b) {int res=1; while (b) {if (b&1) Res=1ll*res*a%mod; A=1ll*a*a%mod; b/=2; } return res; int cal (int u,int R) {memset (g,0,sizeof (g)); for (int i=1;i<n;i++) for (int j=1;j<=i;j++) g[i]=1ll* (G[i]+1ll*pow (j,n-r) *pow (i-j,r-1)%mod)%mod; int res=0; for (int i=1;i<n;i++) {int a=g[i],b=1; for (int j=1;j<n;j++) {if (i==j) ContiNue a=1ll*a* (u-j)%mod; A= (A+MOD)%mod;//attention prevention for negative b=1ll*b* (i-j)%mod; b= (b+mod)%mod; } res=1ll* (Res+1ll*a*pow (b,mod-2)%mod)%mod; } return res; int main () {//Freopen ("4559.in", "R", stdin); Freopen ("4559.out", "w", stdout); N=read (); M=read (); K=read (); Init (); F[0][n-1]=1; for (int i=1;i<=m;i++) mx[i]=read (); for (int i=1;i<=m;i++) rnk[i]=read (); for (int i=1;i<=m;i++) {int d=cal (mx[i],rnk[i]); for (int j=k;j<=n-1;j++) for (int k=j;k<=n-1;k++) {if (k-j>rnk[i]-1) continue; int tmp=1ll*c[k-j][k]*c[rnk[i]-1-k+j][n-1-k]%mod; f[i][j]=1ll* (f[i][j]+1ll*f[i-1][k]*tmp%mod*1ll*d%mod)%mod; }} printf ("%d\n", F[m][k]); return 0;}
bzoj4559 [JLOI2016] results compare Lagrangian interpolation