0768 - Suma Pare 3

From Bitnami MediaWiki
Revision as of 19:42, 3 April 2023 by Andor Giulia (talk | contribs) (Pagină nouă: == rezolvare == <syntaxhighlight lang="python" line="1"> n, m = map(int, input().split()) matrix = [list(map(int, input().split())) for _ in range(n)] unique_even = set() for i in range(n): for j in range(m): if matrix[i][j] % 2 == 0: unique_even.add(matrix[i][j]) print(sum(unique_even)) </syntaxhighlight>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

rezolvare

<syntaxhighlight lang="python" line="1"> n, m = map(int, input().split()) matrix = [list(map(int, input().split())) for _ in range(n)]

unique_even = set() for i in range(n):

   for j in range(m):
       if matrix[i][j] % 2 == 0:
           unique_even.add(matrix[i][j])

print(sum(unique_even)) </syntaxhighlight>