-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14.danjo.py
29 lines (29 loc) · 872 Bytes
/
14.danjo.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
import sys
sys.stdin = open("input.txt", "r")
T = int(input())
for test_case in range(1, T + 1):
N = int(input())
num = list(map(int, input().split()))
gob = []
for i in range(N):
for j in range(i+1, N):
gob.append(num[i]*num[j])
choijonglist = []
for number in gob:
if number // 10 != 0:
fail = 0
choijong = number
chueum = number % 10
number = number // 10
while number > 0:
temp = number % 10
if temp > chueum:
fail += 1
number = number // 10
chueum = temp
if fail == 0:
choijonglist.append(choijong)
if len(choijonglist)==0:
print('#{} -1'.format(test_case))
else:
print('#{} {}'.format(test_case,max(choijonglist)))