HDU 4372 Count the Buildings
Count the Buildings
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2521 Accepted Submission(s):
817
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.
(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.
1000000007(1e9+7).
3 2 2
3 2 1
1
similar problems for you: 4059 2819 1730 2176 1850
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
const LL MAXN=*1e6+;
LL T,N,F,B;
LL mod=;
LL c[][],s[][];
int main()
{
for(LL i=;i<=;i++)
{
c[i][]=;
c[i][i]=;
s[i][]=;//无法频出环
s[i][i]=;//只能拼出一个环
for(LL j=;j<i;j++)
c[i][j]=(c[i-][j-]%mod+c[i-][j]%mod)%mod,
s[i][j]=(s[i-][j-]%mod+(i-)%mod*s[i-][j]%mod)%mod;
}
scanf("%I64d",&T);
while(T--)
{
scanf("%I64d%I64d%I64d",&N,&F,&B);
printf("%I64d\n",(c[F-+B-][F-]%mod*s[N-][F-+B-]%mod)%mod);
}
return ;
}
HDU 4372 Count the Buildings的更多相关文章
- HDU 4372 Count the Buildings:第一类Stirling数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4372 题意: 有n栋高楼横着排成一排,各自的高度为1到n的一个排列. 从左边看可以看到f栋楼,从右边看 ...
- hdu 4372 Count the Buildings —— 思路+第一类斯特林数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4372 首先,最高的会被看见: 然后考虑剩下 \( x+y-2 \) 个被看见的,每个带了一群被它挡住的楼, ...
- HDU 4372 Count the Buildings [第一类斯特林数]
有n(<=2000)栋楼排成一排,高度恰好是1至n且两两不同.现在从左侧看能看到f栋,从右边看能看到b栋,问有多少种可能方案. T组数据, (T<=100000) 自己只想出了用DP搞 发 ...
- HDU 4372 Count the Buildings——第一类斯特林数
题目大意:n幢楼,从左边能看见f幢楼,右边能看见b幢楼 楼高是1~n的排列. 问楼的可能情况 把握看到楼的本质! 最高的一定能看见! 计数问题要向组合数学或者dp靠拢.但是这个题询问又很多,难以dp ...
- HDU 4372 - Count the Buildings(组合计数)
首先想过n^3的组合方法,即f(i,j,k)=f(i-1,j,k)*(i-2)+f(i-1,j-1,k)+f(i-1,j,k-1),肯定搞不定 然后想了好久没有效果,就去逛大神博客了,结果发现需要用到 ...
- hdu 4372 Count the Buildings 轮换斯特林数
题目大意 n栋楼有n个不同的高度 现在限制从前面看有F个点,后面看有B个点 分析 最高那栋楼哪都可以看到 剩下的可以最高那栋楼前面分出F-1个组 后面分出B-1个组 每个组的权值定义为组内最高楼的高度 ...
- HDU 4372 Count the Buildings 组合数学
题意:有n个点上可能有楼房,从前面可以看到x栋楼,从后面可以看到y栋,问楼的位置有多少种可能. 印象中好像做过这个题,
- 【HDU 4372】 Count the Buildings (第一类斯特林数)
Count the Buildings Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- [Hdu4372] Count the Buildings
[Hdu4372] Count the Buildings Description There are N buildings standing in a straight line in the C ...
随机推荐
- Python排序 插入排序
插入排序从前往后遍历数组的每一个元素,对每一位元素都将其插入到已经有序的部分数组中,所以插入排序的要点就是找出要插入元素在已经有序的部分中的位置,同时,由于插入排序采用原地排序(in-place)算法 ...
- 紫书 习题 8-20 UVa 1620 (找规律+求逆序对)
这道题看了半天没看出什么规律, 然后看到别人的博客, 结论是当n为奇数且逆序数为奇数的时候 无解, 否则有解.但是没有给出证明, 在网上也找到详细的证明--我也不知道是为什么-- 求逆序对有两种方法, ...
- 紫书 习题8-14 UVa 1616(二分+小数化分数+精度)
参考了https://www.cnblogs.com/dwtfukgv/p/5645446.html (1)直接二分答案.说实话我没有想到, 一开始以为是贪心, 以某种策略能得到最优解. 但是想了很久 ...
- POJ 1975 Median Weight Bead
Median Weight Bead Time Limit: 1000ms Memory Limit: 30000KB This problem will be judged on PKU. Orig ...
- hadoop-13-root ssh无密码登陆
hadoop-13-root ssh无密码登陆 生产机器禁止ROOT远程SSH登录: vi /etc/ssh/sshd_config 把 PermitRootLogin yes 改为 PermitRo ...
- hadoop-07-ntp服务检查
hadoop-07-ntp服务检查 cd /etc/more /etc/ntp.conf里面进行了server的配置 service ntpd status / stop/ start 安装ntpd ...
- Android ADB工具-截图和录制视频(五)
Android ADB工具-截图和录制视频(五) 标签(空格分隔): Android ADB 7. 截图和录制视 命令 功能 adb shell screencap –p <path/file& ...
- Java数据库訪问小结
</pre>1.JDBC訪问方法</p><p></p><p>DBHelper类訪问数据库.Dao类写数据訪问,View类进行应用,初学实例图 ...
- 黑马程序猿-----Java之你不得不知道的排序
------<a href="http://www.itheima.com" target="blank">Java培训.Android培训.iOS ...
- Android ListView动画实现方法
在Android中listview是最经常使用的控件之中的一个,可是有时候我们会认为千篇一律的listview看起来过于单调,于是就产生了listView动画,listview载入了动画会让用户体验更 ...