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 MAXN 3007
using namespace std;
const long long mod=1e9+7;
int n,k,nn,kk;
long long dp[MAXN][MAXN];
bool li[MAXN][MAXN];
long long ff(int n,int k){
if(n==nn and k==kk)return 1;
else if(n==nn)return 0;
if(li[n][k])return dp[n][k];
li[n][k]=true;
dp[n][k]=(long long) ff(n+1,k)*k+ff(n+1,k+1)*(n+1-k);
dp[n][k]%=mod;
return dp[n][k];
}
int main(){
cin>>n>>k;
nn=n; kk=k;
cout<<ff(1,1)<<"\n";
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... |