. - 力扣(LeetCode)
class Solution {
public:vector<vector<int>> fileCombination(int target) {vector<vector<int>> vec;vector<int> res;int sum = 0, limit = (target - 1) / 2; // (target - 1) / 2 等效于 target / 2 下取整for (int i = 1; i <= limit; ++i) {for (int j = i;; ++j) {sum += j;if (sum > target) {sum = 0;break;} else if (sum == target) {res.clear();for (int k = i; k <= j; ++k) {res.emplace_back(k);}vec.emplace_back(res);sum = 0;break;}}}return vec;}
};