暴搜 剪枝
枚举固定的位置
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e3+10;
int n,k;
int res;
void dfs(int last,int sum,int cur){
if(cur==k){
if(sum==n)res++;
return;
}
for(int i=last;i+sum<=n;i++)
dfs(i,sum+i,cur+1);
}
int main()
{
cin>>n>>k;
dfs(1,0,0);
cout<<res;
}