Hdoj Title 4372 count The buildings (Sterling number of first Class)

Source: Internet
Author: User

Count the buildingsTime limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 738 Accepted Submission (s): 246


Problem Descriptionthere is N buildings standing in a straight on the city, and numbered from 1 to N. The heights of all the buildings is distinct and between 1 and N. Can see F Buildings if you standing in front of the first building and looking forward, and B buildings Behind the last building and looking backward. A building can seen if the building is higher than all building between you and it.
Now, given N, F, B, your task was to figure out how many ways all the buildings can.
Inputfirst line of the input was a single integer T (t<=100000), indicating there was t test cases followed.
Next T lines, each line consists of three integer N, F, B, (0<n, F, b<=2000) described above.
Outputfor each case, you should output the number of ways mod 1000000007 (1e9+7).
Sample Input
23 2 23) 2 1

Sample Output
21st

Source2012 multi-university Training Contest 8
Recommendzhuyuanchen520 | We have carefully selected several similar problems for you:4059 1098 1130 1131 1134 AC Code
#include <stdio.h> #include <string.h> #define MOD 1000000007__int64 s[2010][2010],c[2010][2010],n,f,b; void Fun () {    int i,j;    for (i=0;i<2010;i++)    {        c[i][0]=1;        C[i][i]=1;        s[i][0]=0;        S[i][i]=1;        for (j=0;j<i;j++)        {            c[i][j]= (c[i-1][j-1]+c[i-1][j])%mod;            S[i][j]= (s[i-1][j]* (i-1)%mod+s[i-1][j-1])%mod;}}    int main () {    int t;    Fun ();    scanf ("%d", &t);    while (t--)    {        scanf ("%i64d%i64d%i64d", &n,&f,&b);        printf ("%i64d\n", C[b+f-2][f-1]*s[n-1][f+b-2]%mod);}    }

Hdoj Title 4372 count The buildings (Sterling number of first Class)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.