프로그래밍/알고리즘
백준 알고리즘 1037번 : 약수 (JAVA)
김민쏭
2019. 10. 19. 04:40
C++ : https://1nnovator.tistory.com/31
REPOSITORY
1nnovator.tistory.com
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package java_algorithm;
import java.util.Arrays;
import java.util.Scanner;
public class Baekjoon_1037 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for(int i=0; i<n; i++) {
arr[i] = sc.nextInt();
}
Arrays.sort(arr);
int result = 0;
result = arr[0] * arr[n-1];
System.out.println(result);
}
}
|
cs |
사실상 정렬 한 번과 공식 한 번으로 풀리는 문제라, 큰 어려움은 없었다.