-
Notifications
You must be signed in to change notification settings - Fork 8
/
1039.cpp
53 lines (44 loc) · 946 Bytes
/
1039.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// 1 2 3 4 5 6 7
//1 1 1 1 1 1 1 1
//2 1 1 2 2 3 3
//3 1 1 1
#include <cassert>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <set>
#include <algorithm>
#define N 201
#define K 7
using namespace std;
int main() {
int n, k;
scanf("%d %d", &n, &k);
if (n==0 || k==0) {
cout << 0;
return 0;
}
int dp[K][N];
for(int i=1; i<=n; i++) {
for(int j=1; j<=i&&j<=k; j++) {
if(j==1) {
dp[i][j]=1;
continue;
}
if(j==i) {
dp[i][j]=1;
continue;
}
dp[i][j]=0;
int kk=i-j;
for(int jj=1; jj<=kk; jj++) {
dp[i][j]+=dp[kk][jj];
}
//cout << "dp[" << i << "][" << j << "]=" << dp[i][j] << endl;
}
}
cout << dp[n][k] << endl;
return 0;
}