Title Link: http://acm.hznu.edu.cn/JudgeOnline/problem.php?id=1524
After a simple analysis can know each hand-held two yuan in front of the children, the conductor has at least one yuan in hand.
Suppose that DP (I, j) represents a queueing method (not duplicated) when I have a 1 and a J of 2 yuan, then there are:
DP (i, J) =∑k[0, J]DP (I-1, k), (I >= J)
It is also a new arrangement method to talk about the different positions of n individuals and K individuals. Then the last to multiply A (k,k) *a (n,n)
1#include <algorithm>2#include <iostream>3#include <iomanip>4#include <cstring>5#include <climits>6#include <complex>7#include <fstream>8#include <cassert>9#include <cstdio>Ten#include <bitset> One#include <vector> A#include <deque> -#include <queue> -#include <stack> the#include <ctime> -#include <Set> -#include <map> -#include <cmath> + - using namespacestd; + A Const intMAXN = the; at intN, M, K; - intDP[MAXN][MAXN]; - - intMain () { - //freopen ("in", "R", stdin); -scanf" %d%d%d", &m, &n, &k); inMemset (DP,0,sizeof(DP)); - intAK =1, an =1; to for(inti =1; I <= K; i++) AK *=i; + for(inti =1; I <= N; i++) An *=i; -dp[1][0] =1; thedp[1][1] =1; * for(inti =2; I <= N; i++) { $ for(intj =0; J <= I; J + +) {Panax Notoginseng for(intK =0; K <= J; k++) { -DP[I][J] + = dp[i-1][k]; the } + } A } theprintf"%d\n", dp[n][k]*ak*an ); + return 0; -}
[HZNUOJ1524] Queue for tickets (DP)