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
2749 – Tată
(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"> def sunt_restrictii_incorecte(n, t): # Verifică restricțiile pentru n if not (1 <= n <= 100000): return True # Verifică restricțiile pentru t[i] for i in range(n): if not (0 <= t[i] <= n): return True return False def este_vector_de_tati(t): n = len(t) # Verifică dacă restricțiile sunt respectate if sunt_restrictii_incorecte(n, t): return False # Verifică dacă rădăcina arborelui este corectă if t[0] != 0: return False # Verifică dacă fiecare element al vectorului este un index valid for i in range(1, n): if not (0 <= t[i] < n): return False return True # Citeste numarul n n = int(input("Introduceti numarul n: ")) # Ieși din program dacă restricțiile pentru n nu sunt respectate if n < 1 or n > 100000: print("Datele nu corespund restrictiilor impuse") else: # Citeste vectorul t t = list(map(int, input("Introduceti vectorul t: ").split())) # Verifica daca restrictiile sunt respectate si afiseaza mesajul corespunzator if sunt_restrictii_incorecte(n, t): print("Datele nu corespund restrictiilor impuse") else: # Verifica daca t este vector de tati si afiseaza rezultatul if este_vector_de_tati(t): print("DA") else: print("NU") </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