Count the Buildings HDU - 4372(第一类斯特林数)

Count the Buildings

 HDU - 4372 

题意:n个高楼,问从左边看到f座,从右边看到b座的情况有多少种。

第一类斯特林数~

最高的楼一定可以看到,不用考虑。

剩下n-1座楼,左边要求有f-1个环排列,右边要求有b-1个环排列。然后把每个环最高的楼放到前面(相对)。

即n-1座楼中找f+b-2个环排列,再从f+b-2个环排列中找f-1个方法到左边。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 const int mod = 1e9+7;
 5 const int maxn = 2010;
 6 ll s1[maxn][maxn], c[maxn][maxn];
 7 void init(){
 8     c[0][0] = 1;
 9     for(int i = 1; i < maxn; i++) {
10         s1[i][0] = 0;
11         s1[i][i] = 1;
12         c[i][0] = c[i][i] = 1;
13         for(int j = 1; j < i; j++) {
14             c[i][j] = (c[i-1][j-1] + c[i-1][j]) % mod;
15             s1[i][j] = (s1[i-1][j-1] + (i-1)*s1[i-1][j]) % mod;
16         }
17     }
18 }
19 int main(){
20     int n, b, f;
21     int t;
22     scanf("%d", &t);
23     init();
24     while(t--) {
25         scanf("%d %d %d", &n, &f, &b);
26         printf("%lld\n",c[f+b-2][f-1] * s1[n-1][f+b-2] %mod);
27     }
28 }
View Code

 

转载于:https://www.cnblogs.com/yijiull/p/7601900.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值