和为S的连续正数序列(暴力解法)
和为S的连续正数序列
http://www.nowcoder.com/questionTerminal/c451a3fd84b64cb19485dad758a55ebe
class Solution { public: vector<vector<int> > FindContinuousSequence(int sum) { vector<vector<int>> result; vector<int> num; for(int i=1;i<=sum;i++){ int he=0; for(int j=i;j<=sum;j++){ he+=j; if(he==sum){ for(int k=i;k<=j;k++){ num.push_back(k); } } } if(num.size()>=2){ result.push_back(num); } num.clear(); } return result; } };