Created
October 22, 2013 14:29
-
-
Save Abreto/7101702 to your computer and use it in GitHub Desktop.
Wikioi - Problem 1039.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Wikioi - Proeblem 1039 . by Abreto. */ | |
#include <stdio.h> | |
#define MAXN 200 | |
#define MAXK 6 | |
int f[MAXN+1][MAXN+1][MAXK+1] = {{{0}}}; | |
int | |
dp(int i, int n, int k) | |
{ | |
int j = 0; | |
int *ans = &(f[i][n][k]); | |
if(*ans) | |
return (*ans); | |
if( 1 == k ) | |
if( i <= n ) | |
return (*ans = 1); | |
else | |
return (*ans = 0); | |
for(j = i;j <= n/2;j++) | |
{ | |
*ans += dp(j,n-j,k-1); | |
} | |
return (*ans); | |
} | |
int | |
main(void) | |
{ | |
int N = 0, K = 0; | |
scanf("%d %d", &N, &K); | |
printf("%d\n", dp(1,N,K)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment