2014
02-17

# Stools

Patti and Terri run a bar in which there are 15 stools. One day, Darrell entered the bar and found that the situation how customers chose the stools were as follows:
OOEOOOOEEEOOOEO
O means that the stool in a certain position is used, while E means that the stool in a certain position is empty (here what we care is not who sits on the stool, but whether the stool is empty).As the example we show above, we can say the situation how the 15 stools is used determines 7 intervals (as following):
OO E OOOO EEE OOO E O

Now we postulate that there are N stools and M customers, which make up K intervals. How many arrangements do you think will satisfy the condition?

There are multi test cases and for each test case:
Each case contains three integers N (0<N<=200), M (M<=N), K (K<=20).

There are multi test cases and for each test case:
Each case contains three integers N (0<N<=200), M (M<=N), K (K<=20).

3 1 3
4 2 4

1
2

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<queue>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<iostream>
#include<map>
using namespace std;
#define inf 0x3f3f3f3f
#define Max 110
int max(int a,int b)
{
return a>b?a:b;
}
int min(int a,int b)
{
return a<b?a:b;
}
__int64 dp[220][220][22][2];
int n,m,k;
void init()
{
int i,j,k;
memset(dp,0,sizeof(dp));
dp[1][1][1][1]=1;
dp[1][0][1][0]=1;
for(i=1;i<201;i++)
dp[i][0][1][0]=1;
for(i=2;i<201;i++)
for(j=1;j<=i;j++)
for(k=1;k<=20&&k<=i;k++)
{
dp[i][j][k][0]=dp[i-1][j][k][0]+dp[i-1][j][k-1][1];
dp[i][j][k][1]=dp[i-1][j-1][k][1]+dp[i-1][j-1][k-1][0];
}
}
int main()
{
init();
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
printf("%I64d\n",dp[n][m][k][0]+dp[n][m][k][1]);
}
}