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
2827 - Sir 12
(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="python" line="1"> # 2827 - Sir 12 import sys def valideaza_datele_intrare(sequenta): if len(sequenta) > 1000000 or any(n < 1 or n > 1000000000 for n in sequenta): print("Datele nu corespund restricțiilor impuse.") sys.exit(0) print("Datele sunt introduse corect.") def gaseste_maxime_pare_precedati_de_3_impare(sequenta): cnt = 0 max1, max2 = -1, -1 for n in sequenta: if n % 2 == 1: cnt += 1 elif cnt == 3: if n > max1: max2 = max1 max1 = n elif n > max2: max2 = n if max1 != -1 and max2 != -1: return max2, max1 else: return None if __name__ == "__main__": with open("sir12.in") as fin, open("sir12.out", "w") as fout: # citeste datele de intrare sequenta = list(map(int, fin.readline().split())) # valideaza datele de intrare valideaza_datele_intrare(sequenta) # gaseste cei mai mari doi termeni pari maxime_pare = gaseste_maxime_pare_precedati_de_3_impare(sequenta) if maxime_pare is not None: fout.write(f"{maxime_pare[0]} {maxime_pare[1]}") else: fout.write("Nu exista") </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