blob: bafd30ef0351fc32f026833e7fb0608fd69bf80d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <stdio.h>
#include <stdlib.h>
#define MAX(x,y) ((x)>(y)?(x):(y))
int vsote (int n, int m) {
int r = 0;
if (!n)
return 1;
for (int a = 1; a <= n; a++)
for (int b = MAX(m, a); a*b <= n; b++)
if (n-a*b >= 0)
r += vsote(n-a*b, m);
return r;
}
int main (void) {
int n, m;
scanf("%d %d\n", &n, &m);
printf("%d\n", vsote(n, m));
}
|