2019.08.25 school race simulation Graph


In fact, this is very difficult to track the inclusion and exclusion.
I directly on the test considered \ (m = 0 \) violence and white to \ (m = \ cfrac {n (n-1)} {2} \) of \ (10 \) points.
white to that is a complete graph, meaning of the questions will only need to output \ (0 \) on the line.
As for \ (m = 0 \) a \ (40pts \) , little thought We will find it and wrong row is bijective relationship ...
so, directly wrong row just fine.
but I forgot what was wrong row formula is a recursive ... also thought up ...
so I hand on delusions of inclusion-exclusion form the wrong row, but I was dead, did not launch it.
so I \ (10pts \) leave.
later in the \ (wqy \) guidance pushdown out, this sub-sub-long :
\ [D_n = \ sum_ {I} = 0 {n-^ (-1) ^ I \ left (\ Array the begin {} {} I {C} \\ {J} \} End {Array \ right) (n- -! i)} \]
how to launch it?
you consider mandatory \ (i \) points \ (P_i = i \) , then the program is\ (\ left (\ Array the begin {} {} I {C} \\ {J} \} End {Array \ right) (n--! I) \) .
We then selected \ (I \) points on the line , and this thing out of this sub-sub-Liao ~ ~
\ (Code: \)

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = a ; i <= b ; ++ i)
#define per(i,a,b) for (int i = a ; i >= b ; -- i)
#define pii pair < int , int >
#define X first
#define Y second
#define rint read<int>
#define int long long
#define pb push_back

using std::set ;
using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;

template < class T >
    inline T read () {
        T x = 0 , f = 1 ; char ch = getchar () ;
        while ( ch < '0' || ch > '9' ) {
            if ( ch == '-' ) f = - 1 ;
            ch = getchar () ;
        }
        while ( ch >= '0' && ch <= '9' ) {
            x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
            ch = getchar () ;
       }
   return f * x ;
}

const int mod = 1e9 + 7 ;
const int N = 2e3 + 100 ;

int n , m , ans ;
int C[N][N] , g[N] ;

signed main() {
    n = rint () ; m = rint () ; g[0] = 1 ;
    rep ( i , 0 , n ) C[i][0] = 1 ; rep ( i , 1 , n ) g[i] = g[i-1] * i % mod ;
    rep ( i , 1 , n ) rep ( j , 1 , i ) C[i][j] = ( C[i-1][j-1] + C[i-1][j] ) % mod ;
    rep ( i , 0 , n ) ans = ( ans + ( ( i & 1 ) ? - 1 : 1 ) * C[n][i] % mod * g[n-i] % mod ) % mod ;
    printf ("%lld\n" , ans ) ;
    system ("pause") ; return 0 ;
}

Guess you like

Origin www.cnblogs.com/Equinox-Flower/p/11408818.html