思路 10w询问,a、b范围2k 递推
- 证明
#include <iostream>
using namespace std;
const int N = 2010, mod = 1e9 + 7;
int n, a, b;
int c[N][N];
void init()
{
for (int i = 0; i < N; i ++ )
for (int j = 0; j <= i; j ++ )
if (!j) c[i][j] = 1; //在可选的苹果中选0个,就是不选,也是一种选择
else c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
}
int main()
{
cin >> n;
init();
while (n -- )
{
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", c[a][b]);
}
return 0;
}