(0,0)(x、y)に異なるパスの数、正方向XYにのみシングルステップ、Y = Xとは超えることができない
、それは(X、Y)が出力され-1に達していない場合。入力フォーマット:
二つの整数X、Yの行は、スペースで区切られています。入力は、x = yのを確実。| X |≤2000、| Y |≤2000
出力フォーマット:
行整数が大きくなる可能性があるので、へモジュロ1E9 + 7のあなたは出力のみに必要その結果
、それは(X、Y)に到達できない場合は、出力は-1。サンプル入力:
1 1
出力例:
1
アプリケーションのカトレア番号
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int maxn=4100;
int c[maxn][maxn];
int main(){
int x,y;
cin >> x >> y;
if(x<0 || y<0) //只能沿正方向运动
cout << -1 << endl;
else{
for(int i=0; i<=4000; i++) //初始
c[i][0] = c[i][i] = 1;
for(int i=2; i<=4000; i++) //组合数的运算
for(int j=1; j<=i/2; j++){ //算一半即可
c[i][j] = (c[i-1][j] + c[i-1][j-1])%mod;
c[i][i-j] = c[i][j];
}
cout << (c[2*x][x]-c[2*x][x-1]+mod)%mod << endl;
}
return 0;
}