# 11370: 【原1370】赫萝的桃子

### 题目描述

author: SSY 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/1370

## Sample Input

``````2
7 3
6 2
``````

## Sample Output

``````4
3
``````

## WashSwang's solution

``````#include <iostream>
#include <cstring>
using namespace std;
int n,a,b,t[41][161][161],ans,sum;//第i天，吃j个，总共k个
int main() {
cin>>n;
for (int q=0;q<n;++q)
{
memset(t,0,sizeof(t));
cin>>a>>b;
t[0][0][0]=1;
for (int i=1;i<=b;++i){
for (int k=0;k<=a;++k){
sum=0;
for (int j=0;j<=a-k;++j){
sum+=t[i-1][j][k];
if (j!=0) t[i][j][k+j]=sum;
}
}
}
ans=0;
for (int i=1;i<=a;++i)
ans+=t[b][i][a];
cout<<ans<<endl;
}
return 0;
}
``````

## yyong119's solution

``````#include <cstdio>
#include <algorithm>
#define MAX_A 165
#define MAX_B 45
using namespace std;
int f[MAX_A][MAX_B];

int main() {
int case_num;
scanf("%d", &case_num);
f[0][0] = 1;
for (int i = 0; i < MAX_A; ++i)
f[i][1] = 1;
for (int i = 1; i < MAX_A; ++i)
for (int j = 1; j <= min(i, MAX_B - 1); ++j)
f[i][j] = f[i - 1][j - 1] + f[i - j][j];
int a, b;
while(case_num--) {
scanf("%d%d", &a, &b);
printf("%d\n", f[a][b] >> 1);
}
return 0;
}
``````