-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path111.cpp
More file actions
53 lines (45 loc) · 1.03 KB
/
Copy path111.cpp
File metadata and controls
53 lines (45 loc) · 1.03 KB
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
/*************************************************************************
> File Name: 111.cpp
> Author: dulun
> Mail: dulun@xiyoulinux.org
> Created Time: 2016年03月11日 星期五 18时01分58秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;
const int N = 50086;
int dp[208][10];
int f(int m, int p)
{
if(dp[m][p] > 0) return dp[m][p];
if(m < p) return 0;
if(p == 1) return dp[m][p] = 1;
return dp[m][p] = f(m-1, p-1) + f(m-p, p);
}
int main()
{
int n, k;
cin>>n>>k;
// for(int i = 1; i <= n; i++)
// {
// dp[i][1] = 1;
// dp[i][i] = 1;
// }
dp[0][0] = 1;
f(n, k);
cout<<dp[n][k]<<endl;
memset(dp, 0, sizeof(dp));
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= k ; j++ )
{
if(i >= j)
dp[i][j] = dp[i-1][j-1] + dp[i-j][j];
}
}
// cout<<dp[n][k];
}