###### UVA 题目10128 Queue（DP）
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. Its 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
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 begins with a line containing a single integer number N that indicates the number
of people in a queue (1 ≤ N ≤ 13). Then follows line containing two integers. The first integer
corresponds to the number of people, that we can see looking from the beginning. The second integer
corresponds to the number of people, that we can see looking from the end.
Output
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
Sample Output
90720
1026576

1

ac代码

 16452698 10128 Queue Accepted C++ 0.003 2015-11-18 02:59:23

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL dp[22][22][22];
void fun()
{
int i,j,k;
dp[1][1][1]=1;
for(i=2;i<=13;i++)
{
for(j=1;j<=i;j++)
{
int r=i-j+1;
for(k=1;k<=r;k++)
{
dp[i][j][k]=dp[i-1][j][k-1]+dp[i-1][j-1][k]+(i-2)*dp[i-1][j][k];
}
}
}
}
int main()
{
int t;
scanf("%d",&t);
fun();
while(t--)
{
int n,m,r;
scanf("%d%d%d",&n,&m,&r);
printf("%lld\n",dp[n][m][r]);
}
}


#### uva10128(Queue)

2016-03-28 21:46:03

#### uva 10128 Queue （dp）

2014-08-22 22:37:27

#### UVa 10128 Queue (DP)

2013-11-25 20:59:08

#### uva 10128 - Queue（dp）

2013-11-06 16:54:05

#### UVA 10128 - Queue(dp)

2013-11-15 21:55:17

#### uva 102 357 484 702709 714 825 10128解法与代码

2011年08月30日 130KB 下载

#### UVA - 10128 Queue （DP？DFS）

2017-02-10 19:31:00

#### UVa116 Unidirectional TSP（DP）

2016-09-23 13:51:33

#### Uva 10128 - Queue 递推

2013-09-28 22:39:08

#### UVA Team Queue

2014-05-19 00:14:28

## 不良信息举报

UVA 题目10128 Queue（DP）