백준 1037 약수 / C++

이유참치·2025년 7월 31일

백준

목록 보기
5/249

문제 : 1037

풀이 point

원래 수를 구하기 위해 약수들을 정렬한 후 맨 첫번째 약수와 마지막 약수를 곱한다.

코드

//백준 1037, 약수

#include <iostream>
#include <algorithm>

int divi[51];

int main(){

    int N;
    std::cin >> N;
    
    for(int i{0}; i<N; ++i){
        std::cin >> divi[i];
    }

    std::sort(divi, divi+N);

    std::cout <<  divi[0] * divi[N-1];

    return 0;
}

2025-01-23T14:27:28.184Z

profile
임아리 - 대학생

0개의 댓글