3 = 1 + 1 +
3 = 2 + 1
= 3
then the q (n, m) indicative of the division of n does not exceed the maximum value m of the program book, q (3,3) = 3.
【answer】
q (n, m) = q (nm, m) + q (n, m-1); // put a hold m + m at the beginning in the beginning and then try <= m. 1-
Q (0, m) = . 1; ①
n-<0 || m <= 0 -> F (n-, m) = 0 ②
① before ②.
[Code]
#include <cstdio>
#define ll long long
using namespace std;
//计算n的划分个数,其中最大数不超过m
ll q(int n,int m){
if (n==0) return 1;//0的划分只有一个,那就是它本身
if (n<0 || m<=0) return 0;
if (n<m) return q(n,n);
return q(n-m,m) + q(n,m-1); //放一个m在开头+不放m了
}
int main(){
int n,m;
scanf("%d%d",&n,&m);
printf("%lld\n",q(n,m));
return 0;
}