【第一类斯特林数】HDU_4372_ Count the Buildings
来源:互联网 发布:csol辅助源码 编辑:程序博客网 时间:2024/04/28 11:43
Count the Buildings
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2051 Accepted Submission(s): 676
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.
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.
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
23 2 23 2 1
Sample Output
21
Source
2012 Multi-University Training Contest 8
Recommend
zhuyuanchen520
#include <bits/stdc++.h>using namespace std;typedef long long LL;const int maxn=2005;const int mod=1e9+7;LL dp[maxn][maxn],c[maxn][maxn];void Init(int n,int k){ c[0][0]=1; for(int i=1;i<=n;i++){ c[i][0]=1; for(int j=1;j<=i;j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod; } for(int i=0;i<=n;i++) dp[0][i]=0; dp[1][1]=1; for(int i=2;i<=n;i++) for(int j=1;j<=i;j++) dp[i][j]=(dp[i-1][j-1]%mod+(i-1)%mod*dp[i-1][j]%mod)%mod;}int main(){ int t,N,F,B; Init(2000,2000); scanf("%d",&t); while(t--){ scanf("%d%d%d",&N,&F,&B); if(F+B-1>N){ puts("0"); continue; } LL ans=dp[N-1][F-1+B-1]*c[F-1+B-1][F-1]%mod; printf("%I64d\n",ans); } return 0;}
阅读全文
0 0
- 【第一类斯特林数】HDU_4372_ Count the Buildings
- [HDU 4372]Count the Buildings(第一类斯特林数+组合数)
- [第一类斯特林数 组合] HDU 4372 Count the Buildings
- hdu4372(第一类斯特林数) Count the Buildings
- hdu 4372 Count the Buildings(第一类斯特林数)
- HDU 4372 Count the Buildings(第一类Stirling数)
- #HDU4372#Count the Buildings(第一类Stirling数经典)
- hdu3625 Examining the Rooms && hdu4372 Count the Buildings(第一类斯特林数)
- HDU4372Count the Buildings(第一类斯特林数)
- HDOJ 4372 Count the Buildings(第一类斯特林数+组合数)
- HDU4372-Count the Buildings(第一类Stirling数+组合计数)
- HDU 4372 Count the Buildings(组合数学,第一类Stirling数)
- 4372 Count the Buildings(2012 Multi-University Training Contest 8)第一类strling数
- HDOJ 题目4372 Count the Buildings(斯特林第一类数)
- hdu4372 Count the Buildings
- Count the Buildings HDU
- hdu 4372 Count the Buildings
- HDU 4372 Count the Buildings
- linux命令学习总结(1)
- A. Unimodal Array
- spring mvc基础篇(十三):综合案例二(注解版)
- webservice 调用以及SOAPMessage的组装与解析
- C#线程相关知识点2(线程调用注意事项)
- 【第一类斯特林数】HDU_4372_ Count the Buildings
- Maven出现 Unable to locate the Javac Compiler in解决方法
- 洛谷P3389 【模板】高斯消元法
- Java抽象类和接口的区别
- oracle10G/11G官方下载地址集合 直接迅雷下载
- poj3070 Fibonacci(矩阵倍增模板)
- Service和IntentService中显示Toast的有什么区别
- 自旋锁和互斥锁的区别 java中lock Syntronized区别
- Unity通过Attribute代替getComponent获取组件