[SW Expert Academy, SWEA 6190] 정곤이의 단조 증가하는 수 (python)
Problem Solving/SWEA

[SW Expert Academy, SWEA 6190] 정곤이의 단조 증가하는 수 (python)

728x90

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AWcPjEuKAFgDFAU4&categoryId=AWcPjEuKAFgDFAU4&categoryType=CODE&problemTitle=&orderBy=SUBMIT_COUNT&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


※ SW Expert 아카데미의 문제를 무단 복제하는 것을 금지합니다.

728x90

내 생각

이 문제는 문제 푸는 시간보다 문제 이해하는 시간이 더 오래 걸렸다.

4개의 정수 2, 4, 7, 10를 줬을 때, 2 x 4, 2 x 7, 2 x 10, 4 x 7, 4 x 10, 7 x 10 중 단조 증가하는 수를 구하면 된다.

# 테스트 케이스의 수 t
t = int(input())

for test_case in range(1, t + 1):
    n = int(input())
    a = list(map(int, input().split()))

    max_mul = -1
    for i in range(n - 1):
        for j in range(i + 1, n):
            mul = a[i] * a[j]
            num = list(str(mul))
            result = True
            for k in range(len(num) - 1):
                if num[k] > num[k + 1]:
                    result = False
                    break
            
            if result == True:
                max_mul = max(max_mul, mul)

    print("#{} {}".format(test_case, max_mul))
728x90