본문 바로가기
C++

[프로그래머스] 순서쌍의 개수

by 띰쥬 2025. 9. 4.
728x90
반응형
SMALL

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int solution(int n) {
    int answer = 0;
    vector<int> nums1;

    // n의 약수들을 구해서 오름차순, 내림차순 각각 구하기
    for(int i=1; i<n+1; i++){
         if(n%i==0)
            nums1.push_back(i);
    }
    
    return nums1.size();
}

728x90
반응형
LIST

댓글