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>
#pragma GCC optimize("Ofast")
using namespace std;
const int MOD=1e9+7;
int dp[3005][3005];
int main()
{
#ifdef HOME
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,k,i,j;
cin>>n>>k;
dp[0][0]=1;
for(i=0; i<=n; i++)
for(j=0; j<=k; j++)
{
dp[i+1][j]=(dp[i+1][j]+1LL*j*dp[i][j])%MOD;
dp[i+1][j+1]=(dp[i+1][j+1]+1LL*(i+1-j)*dp[i][j])%MOD;
}
cout<<dp[n][k];
return 0;
}
# | 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... |