This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Noszály Áron 10o Debreceni Fazekas Mihály Gimnázium
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double PI=acos(-1);
template<typename T> T getint() {
T val=0;
char c;
bool neg=false;
while((c=gc()) && !(c>='0' && c<='9')) {
neg|=c=='-';
}
do {
val=(val*10)+c-'0';
} while((c=gc()) && (c>='0' && c<='9'));
return val*(neg?-1:1);
}
const ll mod=1e9+7;
ll dp[3001][3001];
ll calc(int i, int j) {
if(i==0 || j==0) return 1;
if(dp[i][j]!=-1) return dp[i][j];
ll ans=0;
if(i>1) ans=(ans+calc(i-2, j-1)*i*(i-1)/2)%mod;
ans=(ans+4*calc(i-1,j-1)*i)%mod;
if(j>1) ans=(ans+calc(i-1,j-2)*i*(j-1))%mod;
ans=(ans+calc(i,j-1))%mod;
return dp[i][j]=ans;
}
int main() {
IO;
memset(dp, -1, sizeof dp);
int a,b;
cin>>a>>b;
cout<<(calc(a,b)-1+mod)%mod<<"\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |