Skip to content

Commit

Permalink
이슈 #367에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 21, 2024
1 parent 8f88c1a commit 0ec7314
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Programmers/소인수분해.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <string>
#include <vector>
#include <set>

using namespace std;

vector<int> solution(int n) {
set<int> answer;

for (int i = 2; i <= n; i++) {
while (n % i == 0) {
answer.insert(i);
n /= i;
}

if (n == 1) {
break;
}
}

return vector<int>(answer.begin(), answer.end());
}

0 comments on commit 0ec7314

Please sign in to comment.