728x90
약수 N개가 주어졌을 때 자연수를 구하는 문제입니다.
가장 작은 약수와 가장 큰 약수를 곱해서 자연수를 구했습니다.
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
int n;
int minN = 987654321;
int maxN = -987654321;
int arr[60];
cin >> n;
memset(arr, 0, sizeof(arr));
for (int i = 1; i <= n; ++i) {
cin >> arr[i];
minN = min(minN, arr[i]);
maxN = max(maxN, arr[i]);
}
cout << minN * maxN << endl;
return 0;
}
'알고리즘' 카테고리의 다른 글
[C++] 백준 2609번 최대공약수와 최소공배수 (0) | 2019.09.02 |
---|---|
[C++] 백준 11653번 소인수분해 (0) | 2019.09.02 |
[C++] 백준 5086번 배수와 약수 (0) | 2019.09.02 |
[C++] 백준 1541번 잃어버린 괄호 (0) | 2019.09.02 |
[C++] 백준 1436번 영화감독 숌 (0) | 2019.09.02 |