class Solution { public: vector<vector<int> > FindContinuousSequence(int sum) { vector<vector<int> > result; int small=1; int big=2; int smallMax=(sum+1)/2; //最多两数相加 所以 small只能到 (sum+1)/2 while(small<smallMax) { int csum=(small+big)*(big-small+1)/2; if( csum== sum ) //算这区间的和 { int small_save=small;//不能动big vector<int> res; for(int k=0;k<(big-small+1);k++) //把当前找好这组数 放入 { res.push_back(small_save); small_save++; } result.push_back(res);//必须往里面添加数组 //res.clear(); small++; }else if( csum < sum) //和比期望值要小 { big++; } else if(csum> sum) //和比期望值要小 { small++; } } return result; } };