
난이도: ★☆☆☆☆ • solved on: 2026-01-15

자료구조
알고리즘/기법
핵심 키워드
핵심은 약수는 항상 쌍으로 존재한다는 성질이다.
import java.util.*;
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
long max = Long.MIN_VALUE;
long min = Long.MAX_VALUE;
for (int i = 0; i < n; i++) {
long temp = Long.parseLong(st.nextToken());
if (temp > max) max = temp;
if (temp < min) min = temp;
}
System.out.println(min * max);
}
}
비슷한 유형 (GPT 추천) :
확장 문제 (GPT 추천) :