uva 10128 Queue (dp)
来源:互联网 发布:excel软件下载2017 编辑:程序博客网 时间:2024/05/24 04:43
Queue
There is a queue with N people. Every person has a different heigth. We can see P people, when we are looking from the beginning, and R people, when we are looking from the end.It�s because they are having different height and they are covering each other. How many different permutations of our queue has such a interesting feature?
Input Specification
The input consists of T test cases. The number of them (1<=T<=10000) is given on the first line of the input file.
Each test case consists of a line containing three integer numbers: N that indicates the number of people in a queue (1 <= N <= 13), and then two more integers. The first corresponds to the number of people, that we can see looking from the beginning, and the second �corresponding to the number of people, that we can see looking from the end.
Output Specification
For every test case your program has to determine one integer. Print how many permutations of N people we can see exactly P people from the beginning, and R people, when we are looking from the end.
Sample Input
3
10 4 4
11 3 1
3 1 2
Output for the Sample Input
90720
1026576
1
#include<cstdio>#include<map>#include<queue>#include<cstring>#include<iostream>#include<algorithm>#include<vector>#include<list>#include<set>#include<cmath>using namespace std;const int maxn = 10 + 5;const long long INF = 1e12;const double eps = 1e-6;typedef unsigned long long ULL;typedef long long LL;typedef pair<int, int> P;#define fi first#define se secondLL dp[maxn][maxn][maxn];void pre(){ memset(dp, 0, sizeof dp); dp[1][1][1] = 1; for(int i = 1;i < 13;i++){ for(int j = 1;j <= i;j++){ for(int k = 1;k <= i;k++){ dp[i+1][j+1][k] += dp[i][j][k]; dp[i+1][j][k+1] += dp[i][j][k]; dp[i+1][j][k] += (i-1)*dp[i][j][k]; } } }}int main(){ pre(); int t; cin >> t; while(t--){ int n, p, r; cin >> n >> p >> r; cout << dp[n][p][r] << endl; } return 0;}
- uva 10128 - Queue(dp)
- uva 10128 Queue (dp)
- UVA 10128 - Queue(dp)
- UVa 10128 Queue (DP)
- UVA 题目10128 Queue(DP)
- UVA - 10128 Queue (DP?DFS)
- UVa Problem 10128 Queue (队伍)
- UVA 10128 Queue
- UVA 10128 Queue
- UVA - 10128 Queue
- UVA-10128 Queue
- UVA10128 - Queue(dp)
- Uva 10128 - Queue 递推
- poj 3934 Queue(dp)
- uva 540 Team Queue(队列+模拟)
- UVa 12100 - Printer Queue(模拟)
- UVa 540 Team Queue(团队队列)
- UVa 12100 - Printer Queue(模拟)
- Java文件编译成功后的class文件无法执行
- 二叉树的顺序存储结构
- virtual属性对类继承的影响---学习笔记
- 动画预览
- 任意行数的数据输入表格
- uva 10128 Queue (dp)
- spring配置oracle多个用户的datasource
- IntelliMas环境搭建
- hdu1405
- spring配置oracle多个用户的datasource
- LeetCode Partition List
- ubuntu因“不完整的语言支持”更新后字体变难看的解决
- HDU 1863 畅通工程
- Hibernate配置数据库方言