Skip to content

Commit

Permalink
이슈 #390에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 26, 2024
1 parent 39089e7 commit efe5850
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Programmers/연속된_수의_합.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <string>
#include <vector>

using namespace std;

vector<int> solution(int num, int total) {
vector<int> result;

// 첫 번째 수 계산
int start = (total - (num * (num - 1) / 2)) / num;

// 연속된 수를 계산하여 결과에 추가
for (int i = 0; i < num; ++i) {
result.push_back(start + i);
}

return result;
}

0 comments on commit efe5850

Please sign in to comment.