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
1835 - twoop
(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"> # 1835 - twoop def validare(numarde_elemente, numar_operatii, numar_operatiiv2, sirul, operatiiv1, operatiiv2): if numarde_elemente > 100000 or numarde_elemente < 1 or numar_operatii < 1 or numar_operatiiv2 < 1: raise ValueError for element in sirul: if element > 1000000000 or element < -1000000000: raise ValueError for operatie in operatiiv1: if operatie[0] < 1 or operatie[1] > numarde_elemente or operatie[2] > 1000000000 or operatie[2] < -1000000000: raise ValueError for pozitie in operatiiv2: if pozitie < 1 or pozitie > numarde_elemente: raise ValueError fisier_iesire.write("Datele de intrare corespund restrictiilor impuse\n") def aplica_operatii(sirul, operatii, operatiiv2): for operatie in operatii: for i in range(operatie[0]-1, operatie[1]): sirul[i] += operatie[2] for pozitie in operatiiv2: fisier_iesire.write(str(sirul[pozitie - 1]) + '\n') if __name__ == '__main__': fisier_intrare = open("twoopin.txt", "r") fisier_iesire = open("twoopout.txt", "w") try: numar_elemente, numar_operatii1, numar_operatii2 = map(int, fisier_intrare.readline().split()) sir = list(map(int, fisier_intrare.readline().split())) operatii1 = [list(map(int, fisier_intrare.readline().split())) for _ in range(numar_operatii1)] operatii2 = [int(fisier_intrare.readline()) for _ in range(numar_operatii2)] validare(numar_elemente, numar_operatii1, numar_operatii2, sir, operatii1, operatii2) aplica_operatii(sir, operatii1, operatii2) except ValueError: fisier_iesire.write("Datele de intrare nu corespund restrictiilor impuse") except IndexError: fisier_iesire.write("Datele de intrare nu corespund restrictiilor impuse") </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