class Solution {
public:
vector<vector<int>>ans;
vector<int>path;
void dfs(int u,int n,int k){
if(path.size()+n-u+1<k)return;//剪枝
if(path.size()==k){
ans.push_back(path);
return ;
}
for(int i=u;i<=n;i++){
path.push_back(i);
dfs(i+1,n,k);
path.pop_back();
}
}
vector<vector<int>> combine(int n, int k) {
dfs(1,n,k);
return ans;
}
};