• L


    CF932E

    [第二类斯特林数:n^k = sum_{i=0}^{k} S_2(k,i) * C_{n}^{i} * i! ]

    [sum_{i=0}^{n} C_{n}^{i} *i^k = sum_{i=0}^{n}C_{n}^{i}sum_{j=0}^{k}C_{i}^{j}*S_2(k,j)*j!\ =sum_{j=0}^{k}S_2(k,j)*j!sum_{i=0}^{n}C_{n}^{i}*C_{i}^{j}\ =sum_{j=0}^{k}S_2(k,j)*j!sum_{i=0}^{n}C_{n}^{j}*C_{n-j}^{n-i}\ =sum_{j=0}^{k}S_2(k,j)*j!*C_{n}^{j}sum_{i=0}^{n}C_{n-j}^{n-i}\ =sum_{j=0}^{k}S_2(k,j)*j!*C_{n}^{j}sum_{i=0}^{n}C_{n-j}^{i}\ =sum_{j=0}^{k}S_2(k,j)*j!*C_{n}^{j}sum_{i=0}^{n-j}C_{n-j}^{i}\ =sum_{j=0}^{k}S_2(k,j)*j!*C_{n}^{j} * 2^{n-j}\ ]

    
    #include<bits/stdc++.h>
    using namespace std;
    
    #define int long long 
    
    const int mod = 1e9 + 7;
    
    int ksm(int x,int y){
        int z = 1;
        while(y){
            if(y & 1) z = z * x % mod;
            y >>= 1;
            x = x * x % mod;
        }
        return z;
    }
    
    int n,k;
    int s[5005][5005];
    
    signed main(){
        scanf("%lld%lld",&n,&k);
        
        s[0][0] = 1;
        for(int i = 1; i <= k; ++ i)
        for(int j = 1; j <= k; ++ j)
        s[i][j] = (s[i - 1][j - 1] + s[i - 1][j] * j % mod ) % mod;
        
        int ans = 0;
        int bas1 = 1, bas2 = 1, bas3 = ksm(2,n), inv2 = ksm(2, mod - 2);
        //bas1 j! , bas2 C(n,j), bas3 2^(n-j)
        for(int j = 0; j <= k; ++ j){
           int t = s[k][j];
           t = t * bas1 % mod;
           t = t * bas2 % mod;
           t = t * bas3 % mod;
           ans = ans + t; ans %= mod;
            
           bas1 = bas1 * (j + 1) % mod;
           bas2 = bas2 * (n - j) % mod * ksm(j + 1, mod - 2) % mod;
           bas3 = bas3 * inv2 % mod;
        }
        
        printf("%lld
    ",ans);
        
        
        return 0;
    }
    
    
  • 相关阅读:
    SSO 单点登录
    CPU运行原理及对线程的影响01
    表单设计器
    Session 身份验证
    cookie 身份验证及跨域
    WebService 身份验证01_SoapHeader及 iis windows 集成身份验证
    WebService 代理类型
    WebService
    网络协议的理解 http、udp、tcp 等
    Container
  • 原文地址:https://www.cnblogs.com/zzhzzh123/p/13347231.html
Copyright © 2020-2023  润新知