알고리즘(python)/수학
[Python]수학3 백준 1037
개발일기
2020. 1. 19. 19:32
반응형
문제
https://www.acmicpc.net/problem/1037
약수중 가장 큰값과 가장 작은값을 곱하면 N을 구할수있다.
주어진 배열을 정리한후 가장큰값과 가장 작은값을 곱하면된다.
1 2 3 4 | n=int(input()) factor=list(map(int,input().split())) factor=sorted(factor) print(factor[0]*factor[n-1]) | cs |
여기서도 정렬을 하기보다 가장큰값과 가장 작은값을 찾아서 곱하는게 정렬 후 양끝의
숫자를 곱하는것 보다 빠를것이다.
1 2 3 4 5 6 | n=int(input()) factor=list(map(int,input().split())) # factor=sorted(factor) # print(factor[0]*factor[n-1]) print(max(factor)*min(factor)) | cs |
반응형