Calculate the number of combinations Σ(i=0,n)i*C(n,i)

topic:

Proof of identities in combinatorics: 1. Σ(i=0,n)i^2*C(n,i)=n*(n+1)*2^(n-2);
There is another one: Σ( i=0,n)(1/(i+1)(i+2))C(n,i)=(2^(n+2)-n-3)/((n+1)(n+ 2)) Trouble give a detailed explanation,

answer:

The first one, using (1+x)^n=Σ(i=0,n) C(n,i)*x^i, to derive x on both sides, get:
n*(1+x)^(n -1)=Σ(i=1,n) i*C(n,i)*x^(i-1). Multiply both sides by x, get:
n*x*(1+x)^(n- 1)=Σ(i=1,n) i*C(n,i)*x^i. Take the derivative of x on both sides, get:
n*(1+x)^(n-1)+n*x *(n-1)*(1+x)^(n-2)=Σ(i=1,n) i^2*C(n,i)*x^(i-1). Let x=1 , Sort, and get the proof. The
second one, use A: Σ(i=0,n) C(n,i)=2^n and B:Σ(i=1,n) i*C(n,i) =n*2^(n-1)
.Left formula=Σ(i=0,n) (1/(i+1)-1/(i+2))*C(n,i)
=(1- 1/2)*C(n,0)+(1/2-1/3)*C(n,1)+(1/3-1/4)*C(n,2)+...+ (1/n-1/(n+1))*C(n,n-1)+(1/(n+1)-1/(n+2))*C(n,n)
=C( n,0)-(1/(n+2))*C(n,n)+(1/2)*(C(n,1)-C(n,0))+(1/3)* (C(n,2)-C(n,1))+...+(1/(n+1))*(C(n,n)-(n,n-1))
=1-1 /(n+2)+Σ(i=1,n) (1/(i+1))*(C(n,i)-C(n,i-1))
=(n+1)/( n+2)+Σ (1/(i+1))*(n!/ (i!*(ni)!)-n!/ ((i-1)!*(n-i+1)!) )
=(n+1)/(n+2)+Σ (1/(i+1))*((ni-1-i)*n!) / (i!*(n-i+1)! )
=(n+1)/(n+2)+Σ ((n-2*i+1)/(n+1)*(n+2))*((n+2)!/ ((i+ 1)!*(n-i+1)!))
=(n+1)/(n+2)+1/((n+1)(n+2)) Σ (n+3-2*i -2)*C(n+2,i+1)
=(n+1)/(n+2)+(n+3)/((n+1)*(n+2)) Σ C(n +2,i+1)-2/((n+1)*(n+2)) Σ (i+1)*C(n+2,i+1)
Use A to simplify the second term
= (n +1)/(n+2)+((n+3)*(2^(n+2)-n-4)) / ((n+1)*(n+2))-2/(( n+1)*(n+2)) Σ(i=2,n+1) i*C(n+2,i)
Use B to simplify the third term
=(n+1)/(n+2) +((n+3)*(2^(n+2)-n-4))/((n+1)*(n+2))-(2*((n+2)*2^( n+1)-2*n-4)) / ((n+1)*(n+2))
Then simplify it a bit and you will be proved.

For this question, you can set x=1 when it is the box in the figure, because there is no need to get the coefficient i^2,

It is easy to get Σ(i=0,n)i*C(n,i)=n*2^(n-1), if it is an algorithm problem, you can use fast power for 2^(n-1)

#include<iostream>

using namespace std;
int mm=1000000007;
int main()
{
    int n;
    cin>>n;
    int m=n-1;
    long long a=2,res=1;
    while(m)
    {
        if (m&1) res=res*a%mm;
        a=a*a%mm;
        m=m>>1;
    }
    res=res*n%mm;
    cout<<res<<endl;
    return 0;
}

 

Guess you like

Origin blog.csdn.net/hbhhhxs/article/details/105057009