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
3484 - 3 La N
(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=""> with open('3lan.in', 'r') as fin: # Citirea primului numar din fisierul de intrare si conversia acestuia la intreg folosind functia int numar = int(fin.readline().strip()) # Citirea si conversia elementelor din a doua linie a fisierului de intrare la intregi, stocandu-le intr-o lista a = list(map(int, fin.readline().split())) s = 0 def treilan(x, y): # Calcularea restului impartirii dintre produsul lui 'x' si 'y' la 4 si stocarea rezultatului in variabila 'rest' rest = (x * y) % 4 # Determinarea valorii lui 'nr1' in functie de restul anterior calculat if rest == 0: nr1 = 1 elif rest == 1: nr1 = 3 elif rest == 2: nr1 = 9 else: nr1 = 7 # Calcularea restului impartirii lui 'nr1' la 4 si actualizarea valorii lui 'nr1' nr1 %= 4 # Determinarea valorii lui 'nr2' in functie de 'nr1' if nr1 == 0: nr2 = 1 elif nr1 == 1: nr2 = 3 elif nr1 == 2: nr2 = 9 else: nr2 = 7 # Calcularea restului impartirii lui 'nr2' la 4 si returnarea acestuia nr2 %= 4 if nr2 == 0: return 1 elif nr2 == 1: return 3 elif nr2 == 2: return 9 else: return 7 #Parcurgem toate perechile de numere din intervalul [1, numar] for i in range(1, numar+1): for j in range(i+1, numar+1): # Apelarea functiei 'treilan' cu parametrii 'i' si 'j' si adaugarea rezultatului la variabila 's'. s += treilan(i, j) with open('3lan.out', 'w') as fout: # Verificarea daca valorile din fisierul de intrare respecta conditiile if numar >= 2 and numar <= 1000 and all(aj <= 10000 for aj in a): # Scrierea valorii variabilei 's' in fisierul de iesire print(s, file=fout) else: # Scrierea unui mesaj de eroare in fisierul de iesire in cazul in care datele din fisierul de intrare nu sunt valide print("Datele nu au fost introduse corect.", file=fout) print("Datele nu au fost introduse corect.") </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