//分别设j指向区间左端点,i指向区间右端点,在i往右移动的过程中判断总和sum是否为S:若超过sum,则j往后移动以减小sum
class Solution {
public:
vector<vector<int> > findContinuousSequence(int n) {
vector<vector<int>> res;
int sum = 0;
for(int i=1,j=1;i<=(n+1)/2;i++){
sum += i;
while(sum > n && j < i){
sum -= j;
j++;
}
if(sum == n && j < i){
vector<int> temp;
for(int k=j;k<=i;k++)
temp.push_back(k);
res.push_back(temp);
}
}
return res;
}
};