Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Bitnami MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
3523 - John
(section)
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Rezolvare == <syntaxhighlight lang="python3" line="1"> def max_muncitori_pe_o_casa(numar_muncitori, indici_case): frecventa_case = {} for indice_casa in indici_case: if indice_casa not in frecventa_case: frecventa_case[indice_casa] = 0 frecventa_case[indice_casa] += 1 return max(frecventa_case.values()) def max_case_cu_muncitori(n, m, indici_case_muncitori): frecventa_case = {} for indici_case in indici_case_muncitori: for indice_casa in indici_case: if indice_casa not in frecventa_case: frecventa_case[indice_casa] = 0 frecventa_case[indice_casa] += 1 numar_maxim_case = 0 for frecventa in frecventa_case.values(): if frecventa >= 2: numar_maxim_case += 1 return numar_maxim_case def verificare_date_intrare(n, m, indici_case_muncitori): if not (1 <= n <= 1000) or not (1 <= m <= 1000): return False for indici_case in indici_case_muncitori: if len(indici_case) != m or not all(1 <= indice <= 1000000000 for indice in indici_case): return False return True # Citire date de intrare n = int(input("Introduceți numărul de muncitori (n): ")) m = int(input("Introduceți numărul de case (m): ")) indici_case_muncitori = [] for i in range(n): indici_casa_muncitor = list(map(int, input(f"Introduceți indicii caselor pentru muncitorul {i + 1}, separați prin spațiu: ").split())) indici_case_muncitori.append(indici_casa_muncitor) # Verificare date de intrare if not verificare_date_intrare(n, m, indici_case_muncitori): print("Datele introduse nu corespund restricțiilor impuse") else: # Calcul și afișare rezultate max_muncitori_pe_o_casa_result = max_muncitori_pe_o_casa(n, indici_case_muncitori[0]) max_case_cu_muncitori_result = max_case_cu_muncitori(n, m, indici_case_muncitori) print(f"Numărul maxim de muncitori care lucrează la aceeași casă este: {max_muncitori_pe_o_casa_result}") print(f"Numărul maxim de case la care lucrează simultan cel puțin doi muncitori este: {max_case_cu_muncitori_result}") </syntaxhighlight>
Summary:
Please note that all contributions to Bitnami MediaWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bitnami MediaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width