This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e18;
const ll mod=1e9+7;
ll dp[3005][3005],n,k;
void solve()
{
cin >> n >> k;
dp[1][0]=1;
for(int i=1;i<n;i++)
{
for(int j=0;j<=i-1;j++)
{
dp[i][j]%=mod;
dp[i+1][j+1]+=dp[i][j];
dp[i+1][j]+=dp[i][j];
dp[i+1][j]+=j*dp[i][j]%mod;
dp[i+1][j+1]+=(i-1-j)*dp[i][j]%mod;
}
}
cout << dp[n][k-1];
}
int main()
{
fastio
//freopen(TASKNAME".INP","r",stdin);
//freopen(TASKNAME".OUT","w",stdout);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |