• Count the Buildings HDU


    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
    ",c[f+b-2][f-1] * s1[n-1][f+b-2] %mod);
    27     }
    28 }
    View Code
  • 相关阅读:
    ABAP术语-Interface
    ABAP术语-Interface Parameter
    ABAP术语-Implementation
    ABAP术语-IDOC
    ABAP术语-IAC (Internet Application Components)
    ABAP术语-HTML
    ABAP术语-Function Module
    ABAP术语-Function Library
    ABAP术语-Function Group
    PyCharm的小技巧
  • 原文地址:https://www.cnblogs.com/yijiull/p/7601900.html
Copyright © 2020-2023  润新知