• CF932E Team Work


    Link

    [egin{aligned} ans&=sumlimits_{i=1}^n{nchoose i}i^k\ &=sumlimits_{i=1}^nfrac{n!}{i!(n-i)!}sumlimits_{j=1}^{min(i,k)}left{katop j ight}i^{underline j}\ &=sumlimits_{i=1}^nsumlimits_{j=1}^{min(i,k)}left{katop j ight}frac{n!}{(n-i)!(i-j)!}\ &=sumlimits_{i=1}^{min(n,k)}left{katop i ight}sumlimits_{j=i}^nfrac{n!}{(n-j)!(j-i)!}\ &=sumlimits_{i=1}^{min(n,k)}left{katop i ight}frac{n!}{(n-i)!}sumlimits_{j=i}^n{n-ichoose n-j}\ &=sumlimits_{i=1}^{min(n,k)}left{katop i ight}frac{n!}{(n-i)!}2^{n-i} end{aligned} ]

    #include<cstdio>
    const int N=5001,P=1000000007;
    int S[N][N];
    void inc(int&a,int b){a+=b-P,a+=a>>31&P;}
    int mul(int a,int b){return 1ll*a*b%P;}
    int pow(int a,int k){int r=1;for(;k;k>>=1,a=mul(a,a))if(k&1)r=mul(a,r);return r;}
    int main()
    {
        int n,k,ans=0;scanf("%d%d",&n,&k),S[0][0]=1;
        for(int i=1;i<=k;++i) for(int j=1;j<=i;++j) inc(S[i][j]=S[i-1][j-1],mul(j,S[i-1][j]));
        for(int i=1,t=n;i<=k&&i<=n;++i) inc(ans,1ll*S[k][i]*t%P*pow(2,n-i)%P),t=mul(t,n-i);
        printf("%d",ans);
    }
    
  • 相关阅读:
    linux:yum
    python:公共操作
    python 控制流程
    linux:lamp环境
    linux:nginx
    深圳:永安在线-安全
    linux:mysql
    linux:shell
    linux:项目上线
    linux:权限管理
  • 原文地址:https://www.cnblogs.com/cjoierShiina-Mashiro/p/12701100.html
Copyright © 2020-2023  润新知