背景
(Japan) (Olympiad) (in) (Informatics) (Spring) (Camp) (2018) (Day1) (T3) , (LOJ) (2833)
题意
咕咕咕
解法
细节
代码
$View$ $Code$
//省略头文件 using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } const int mod=1e9+7; int h,w,ans; long long dp[3005][3005]; int main() { h=read(); w=read(); for(int i=0;i<=h;i++) { for(int j=0;j<=w;j++) { if(!i||!j) dp[i][j]=1; else { dp[i][j]=dp[i][j-1]+4*i*dp[i-1][j-1]; if(2<=i) dp[i][j]+=i*(i-1)/2*dp[i-2][j-1]; if(2<=j) dp[i][j]+=i*(j-1)*dp[i-1][j-2]; dp[i][j]%=mod; } } } ans=((dp[h][w]-1)%mod+mod)%mod; printf("%d ",ans); return 0; }