0766 - Nr Pare

From Bitnami MediaWiki
Revision as of 19:45, 3 April 2023 by Andor Giulia (talk | contribs) (Pagină nouă: == Rezolvare == <syntaxhighlight lang="python" line="1"> n, m = map(int, input().split()) max_count = 0 max_rows = [] for i in range(n): row = list(map(int, input().split())) count = sum(1 for x in row if x % 2 == 0) if count > max_count: max_count = count max_rows = [i+1] elif count == max_count: max_rows.append(i+1) if max_count == 0: print("NU EXISTA") else: print(*max_rows) </syntaxhighlight>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Rezolvare

<syntaxhighlight lang="python" line="1"> n, m = map(int, input().split())

max_count = 0 max_rows = []

for i in range(n):

   row = list(map(int, input().split()))
   count = sum(1 for x in row if x % 2 == 0)
   if count > max_count:
       max_count = count
       max_rows = [i+1]
   elif count == max_count:
       max_rows.append(i+1)

if max_count == 0:

   print("NU EXISTA")

else:

   print(*max_rows)

</syntaxhighlight>