# Count the Buildings

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1300    Accepted Submission(s): 422

Problem Description
There are N buildings standing in a straight line in the City, numbered from 1 to N. The heights of all the buildings are distinct and between 1 and N. You can see F buildings when you standing in front of the first building and looking forward, and B buildings when you are behind the last building and looking backward. A building can be seen if the building is higher than any building between you and it.
Now, given N, F, B, your task is to figure out how many ways all the buildings can be.

Input
First line of the input is a single integer T (T<=100000), indicating there are T test cases followed.
Next T lines, each line consists of three integer N, F, B, (0<N, F, B<=2000) described above.

Output
For each case, you should output the number of ways mod 1000000007(1e9+7).

Sample Input
2
3 2 2
3 2 1

Sample Output
2
1

N座高楼，高度均不同且为1~N中的数，从前向后看能看到F个，从后向前看能看到B个，问有多少种可能的排列数。

AC代码：

#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<math.h>
#define INF (1<<30)
#define LL long long
using namespace std;
const int MMAX = 2100 ;
const LL mod = 1e9+7;

LL c[MMAX][MMAX],s[MMAX][MMAX];

void init() //第一类Stirling数
{
for(int i=0; i<MMAX; i++)
{
c[i][0]=c[i][i]=s[i][i]=1;
for(int j=1; j<i; j++)
{
c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
s[i][j]=((i-1)*s[i-1][j])%mod+s[i-1][j-1]%mod;
}
}
}
int main()
{
init();
LL T;
scanf("%I64d",&T);
while(T--)
{
LL n,f,b;
scanf("%I64d%I64d%I64d",&n,&f,&b);
printf("%I64d\n",(c[f+b-2][f-1]*s[n-1][f+b-2])%mod);
}
return 0;
}

### 2 只已被捕捉

• babyQ Chrome | 60.0.3112.90 Windows 10

发现这份代码c++能过，g++就RE啦，然后特判f+b-1>n的时候ans=0就过了= =题目也没说数据保证合法嘛（c++还有这样神奇的功能……(ノ°ο°)ノ）

• 千千 Chrome | 60.0.3112.101 Windows 10

有些时候就是这样咯~ 还会出现 G++ 过 C++ 不过的情况，至今不知道原因~Σ(っ °Д °;)っ