图的价值那道题的简化版?
#include <bits/stdc++.h>
#define SIZE 5003
#define LL long long
#define mod 1000000007
#define setIO(s) freopen(s".in","r",stdin)
using namespace std;
inline int qpow(int x,int y)
{
int tmp=1;
for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) tmp=1ll*tmp*x%mod;
return tmp;
}
inline int INV(int x) { return qpow(x,mod-2); }
int S[SIZE][SIZE],N,K;
inline void Initialize()
{
int i,j;
S[0][0]=1;
for(i=1;i<SIZE;++i) for(j=1;j<=i;++j) S[i][j]=(S[i-1][j-1]+1ll*S[i-1][j]*j%mod)%mod;
}
int main()
{
// setIO("input");
int i,j;
Initialize();
scanf("%d%d",&N,&K);
int Lim=min(N,K),now=1,tmp=N,ans=0;
for(i=0;i<=Lim;++i)
{
ans=(ans+1ll*S[K][i]*qpow(2,N-i)%mod*now%mod)%mod;
now=1ll*now*tmp%mod;
--tmp;
}
printf("%d
",ans);
return 0;
}