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
3152 - combinari2
(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!
= Exemplul 2 = Intrare 22 17 consola Nu corespunde restricțiilor == Rezolvare == <syntaxhighlight lang="python3" line="1"> def este_input_valid(n, m): return 1 <= m < n <= 20 def este_submultime_valida(submultime): for i in range(len(submultime) - 1): if submultime[i] % 2 == 0 and submultime[i + 1] % 2 == 0: return False return True def genereaza_submultimi(n, m, submultime_curenta, index): if len(submultime_curenta) == m: if este_submultime_valida(submultime_curenta): print(*submultime_curenta) return if index > n: return # Include elementul la index în submulțime genereaza_submultimi(n, m, submultime_curenta + [index], index + 1) # Sări peste elementul la index genereaza_submultimi(n, m, submultime_curenta, index + 1) if __name__ == "__main__": n, m = map(int, input("Introduceți valorile pentru n și m (separate prin spațiu): ").split()) if not este_input_valid(n, m): print("Nu corespunde restricțiilor") else: print(f"Submulțimile cu {m} elemente ale mulțimii {{1, 2, ..., {n}}} în care nu există două elemente pare alăturate sunt:") genereaza_submultimi(n, m, [], 1) </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