-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6190_정곤이의단조증가하는수.py
71 lines (53 loc) · 1.58 KB
/
6190_정곤이의단조증가하는수.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# 위에 주석처리한 코드는 답은 나오지만 for문을 많이 돌아서 느리다
# def isIncreasingNum(n):
# temp_list = list(map(int,list(str(n))))
# check = 1
# for i in range(1, len(temp_list)):
# if temp_list[i] < temp_list[i - 1]:
# check = -1
# break
# if check == -1:
# return False
# else:
# return True
# test_num = int(input())
# for t in range(test_num):
# l = int(input())
# base_list = list(map(int, input().split()))
# new_list = []
# for i in range(l - 1):
# for j in range(i+1, l):
# new_list.append(base_list[i] * base_list[j])
# result_list = []
# for i in range(len(new_list)):
# if isIncreasingNum(new_list[i]):
# if len(result_list) == 0:
# ma = new_list[i]
# elif ma < new_list[i]:
# ma = new_list[i]
# print('#' + str(t+1) + ' ', end = '')
# print(ma)
def monotonic(n):
a = n % 10
n = int(n / 10)
while n != 0:
if n % 10 > a:
return False
else:
a = n % 10
n = int(n / 10)
return True
test_num = int(input())
for t in range(test_num):
l = int(input())
base_list = list(map(int, input().split()))
result = -1
for i in range(l - 1):
for j in range(i+1, l):
mul = base_list[i] * base_list[j]
if mul < result:
continue
if monotonic(mul):
result = mul
print('#' + str(t+1) + ' ', end = '')
print(result)