Obviously, there are many things to note about DP. The DP courseware cannot be blindly initialized. In addition, the DP courseware describes the features of DP, the optimal sub-structure, and the optimal local features. The key to finding DP is here.
/* ID: nocowslang: C ++ prog: nocows */# include <stdio. h> # define maxn 201 # define maxk 101 # define mod 9901 using namespace STD; int main () {freopen ("nocows. in "," r ", stdin); freopen (" nocows. out "," W ", stdout); int N, K; int DP [maxn] [maxk]; scanf (" % d ", & N, & K ); for (INT I = 0; I <= N; I ++) for (Int J = 0; j <= K; j ++) DP [I] [J] = 0; For (INT I = 1; I <= K; I ++) DP [1] [I] = 1; for (INT I = 1; I <= K; I ++) for (Int J = 3; j <= N; j + = 2) for (int K = 1; k <j; k + = 2) DP [J] [I] = (DP [J] [I] + dp [k] [I-1] * DP [j-k-1] [I-1]) % MOD; printf ("% d \ n", (DP [N] [k]-DP [N] [K-1] + mod) % mod); Return 0 ;}