문제 링크: https://www.acmicpc.net/problem/1037
백준 정수론 및 조합론 2단계 - 1037번 약수를 풀어보았다.
풀이: 약수를 받아 본래의 수를 구하는 문제이다.
C++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++) cin>>v[i];
sort(v.begin(),v.end());
cout<<v[0]*v[n-1];
}
Python
n=int(input())
arr=list(map(int,input().split()))
arr.sort()
print(arr[0]*arr[-1])
Java
'코테용 문제풀이 > 백준' 카테고리의 다른 글
검문 풀이 (0) | 2023.01.09 |
---|---|
최대공약수와 최소공배수 풀이 (0) | 2023.01.09 |
배수와 약수 풀이 (0) | 2023.01.09 |
어린 왕자 풀이 (0) | 2023.01.09 |
터렛 풀이 (0) | 2023.01.09 |