| 记录编号 | 
        332776 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        26.分组 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         123 | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.018 s  | 
    
    
        | 提交时间 | 
        2016-10-29 09:46:56 | 
        内存使用 | 
        0.31 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
int n,k,ans;
class as{
public: int ya[50];
};
vector <as> yb;
as qw={0};
void bfs(int q,int w){
	int a,b,c,d;
	if(q!=0&&q>=qw.ya[w-1]&&w<=k){
		for (b=1;b<=q;b++){
			if(qw.ya[w]+b>=qw.ya[w-1])
			{
				qw.ya[w]=qw.ya[w]+b;
				bfs(q-b,w+1);
				qw.ya[w]=qw.ya[w+1]=0;
			}
		}
	}
	if(q==0&&w>k){
		ans++;
		yb.push_back(qw);
	}
}
int main(){
	freopen ("dataa.in","r",stdin);
	freopen ("dataa.out","w",stdout);
	int e,f,g;
	cin>>n>>k;
	ans=0;
	bfs(n,1);
	cout<<ans<<endl;
	for (e=0;e<=ans-1;e++)
	{
		for (f=1;f<=k;f++)
		{
			cout<<yb[e].ya[f]<<" ";
		}
		yb.pop_back();
		cout<<endl;
	}
	return 0;
}