Uva 1638 Pole Arrangement DP
来源:互联网 发布:火炮兰捏脸数据2016 编辑:程序博客网 时间:2024/05/20 05:47
倒过来从插入最短的木棒考虑
1638 Pole ArrangementThere are poles of height 1, 2, . . . , n in a row. If you look at these poles from the left side or the rightside, smaller poles are hidden by taller poles. For example, consider the two arrangements of 4 poles inthe next figure:For each arrangement, only one pole can be seen from the left, and two poles can be seen from theright.You are to write a program to calculate the number of arrangements of n poles such that seen fromthe left you see l poles and seen from the right you see r poles.InputYour program is to read from standard input. The input consists of T test cases. The number of testcases T is given in the first line of the input. Each test case consists of a line containing three integers,n, l, and r (1 ≤ l, r ≤ n ≤ 20), where n is the number of poles and l (resp. r) is the number of polesthat can be seen from the left (resp. right).OutputYour program is to write to standard output. Print exactly one line for each test case. The line shouldcontain the number of arrangements of poles for the test case.The following shows sample input and output for four test cases.Sample Input44 1 24 1 15 2 420 2 1Sample Output2046402373705728000
/* ***********************************************Author :CKbossCreated Time :2015年01月29日 星期四 14时51分47秒File Name :UVA1638.cpp************************************************ */#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <string>#include <cmath>#include <cstdlib>#include <vector>#include <queue>#include <set>#include <map>using namespace std;typedef long long int LL;int n,l,r;LL dp[30][30][30];void init(){dp[1][1][1]=1;for(int i=2;i<=20;i++)for(int j=1;j<=20;j++)for(int k=1;k<=20;k++)dp[i][j][k]=dp[i-1][j-1][k]+dp[i-1][j][k-1]+(i-2)*dp[i-1][j][k];}int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int T_T;scanf("%d",&T_T);init();while(T_T--){scanf("%d%d%d",&n,&l,&r);cout<<dp[n][l][r]<<endl;} return 0;}
- Uva 1638 Pole Arrangement DP
- UVA 1638 - Pole Arrangement (dp计数)
- UVa 1638-Pole Arrangement
- UVa 1638 Pole Arrangement
- uva 1638 Pole Arrangement
- UVa 1638 Pole Arrangement
- UVA 1638 Pole Arrangement
- uva 1638 Pole Arrangement
- Uva 1638 Pole Arrangement 数学,递推,dp
- UVA 1638- Pole Arrangement(动态规划)
- uva 1638 Pole Arrangement 递推
- uva 1638 Pole Arrangement (有多少种可能?)
- UVA 1608 Pole Arrangement(递推)
- 1638 - Pole Arrangement (递推)
- UVa1638 Pole Arrangement 递推
- ACM 简单DP Pole Arrangement Regionals 2012 >> Asia - Daejeon 区域赛
- UVALive 6117 (LA 6117) Pole Arrangement 动态规划
- 【组合数学】Pole Arrangement, ACM/ICPC Daejeon 2012, UVa1638
- 可行 虚拟机 centos 配置网络
- 字符,字节和编码
- php购物车类--初步实现
- 12.5 自定义计算的第一步
- python中的map、filter、reduce函数
- Uva 1638 Pole Arrangement DP
- 一个针对于企业招聘永久免费的网站(记录一下)
- yii2 db 操作
- Linux epoll模型
- quartz学习三
- stm32 仿真错误error 65
- Oracle彻底的卸载干净
- Handler消息传递机制(一)
- iOS 关于枚举的使用