传送门
数论题,没什么可以多说,直接证明:
1. 方 案 数 = ∑ i = 1 n i ∗ C n i 1.方案数=\sum_{i=1}^ni*C_n^i 1.方案数=i=1∑ni∗Cni
2. = ∑ i = 1 n i ∗ n ! i ! ( n − i ) ! 2.=\sum_{i=1}^ni*\frac{n!}{i!(n-i)!} 2.=i=1∑ni∗i!(n−i)!n!
3. = ∑ i = 1 n n ! ( i − 1 ) ! ( n − i ) ! 3.=\sum_{i=1}^n\frac{n!}{(i-1)!(n-i)!} 3.=i=1∑n(i−1)!(n−i)!n!
4. = ∑ i = 0 n − 1 ( n − 1 ) ! i ! ( n − 1 − i ) ! 4.=\sum_{i=0}^{n-1}\frac{(n-1)!}{i!(n-1-i)!} 4.=i=0∑n−1i!(n−1−i)!(n−1)!
5. = ∑ i = 0 n − 1 C n − 1 i 5.=\sum_{i=0}^{n-1}C_{n-1}^i 5.=i=0∑n−1Cn−1i
6. = 2 n − 1 6.=2^{n-1} 6.=2n−1
证毕.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define XJQ 1000000007
#define LL long long
using namespace std;
inline LL read() {
LL d=0,f=1;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
return d*f;
}
LL n=read();
LL king(LL w)
{
LL x=1,a=2;
while(w)
{
if(w&1) x=x*a%XJQ;
a=a*a%XJQ;
w>>=1;
}
return x;
}
int main()
{
printf("%lld",king(n-1)*n%XJQ);
return 0;
}