描述
There are N buttons on the console. Each button needs to be pushed exactly once. Each time you may push several buttons simultaneously.
Assume there are 4 buttons. You can first push button 1 and button 3 at one time, then push button 2 and button 4 at one time. It can be represented as a string "13-24". Other pushing way may be "1-2-4-3", "23-14" or "1234". Note that "23-41" is the same as "23-14".
Given the number N your task is to find the number of different valid pushing ways.
输入
An integer N. (1 <= N <= 1000)
输出
Output the number of different pushing ways. The answer would be very large so you only need to output the answer modulo 1000000007.
样例输入
3
样例输出
13
#include<bits/stdc++.h>
#include<stdlib.h>
using namespace std;
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=b-1;i>=a;--i)
const int N=1010;
const LL mod=1e9+7;
LL dp[N][N];
int main()
{
int n;
scanf("%d",&n);
//for(int i=1;i<=n;i++)dp[i][1]=1;
dp[0][0]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
//考虑新加入一个数,会有多少种情况
dp[i][j]=dp[i-1][j]*j%mod+dp[i-1][j-1]*j%mod;
}
}
LL ans=0;
for(int i=1;i<=n;i++)ans=(ans+dp[n][i])%mod;
printf("%lld\n",ans);
return 0;
}