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>
using namespace std;
long long a,b,c,d,e,dp[3009][3009],mod=1000000007;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>b;
for(c=0; c<=a+1; c++){
for(d=0; d<=b+1; d++){
dp[c][d]=1;
}
}
for(c=1; c<=a; c++){
for(d=1; d<=b; d++){
dp[c][d]=c*dp[c-1][d-1]*4+dp[c][d-1];
if(d>1) dp[c][d]+=c*(d-1)*dp[c-1][d-2];
if(c>=2) dp[c][d]+=(c-1)*c/2*dp[c-2][d-1];
dp[c][d]%=mod;
}
}
cout<<(dp[a][b]-1+mod)%mod;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |