-
Notifications
You must be signed in to change notification settings - Fork 0
/
PY02055.py
39 lines (35 loc) · 884 Bytes
/
PY02055.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
def isPrime(k):
if k < 2:
return False
for i in range(2, int(k // 2) + 1):
if k % i == 0:
return False
return True
s = input().split()
n, m = int(s[0]), int(s[1])
matrix = []
for i in range(n):
a = input().split()
l_1 = []
for i in a:
l_1.append(int(i))
matrix.append(l_1) # Nhập ma trận bằng list
matrix_tmp = matrix.copy()
flat_list = [item for sublist in matrix_tmp for item in sublist] # chuyển list lồng nhau về list đơn để tim max, min
flat_list.sort(reverse=True)
r = 0
flag = 0
for i in flat_list:
if isPrime(i):
flag = 1
r = i
break
if flag:
print(r)
for i in range(n):
for j in range(m):
if matrix[i][j] == r:
t = "Vi tri [" + str(i) + "]" + "[" + str(j) + "]"
print(t)
else:
print("NOT FOUND")