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
1351 - Nano
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
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"> # 1351 - Nano import math def este_patrat_perfect(n): radacina = math.isqrt(n) return radacina * radacina == n def validare(numere_validare, fisier_iesire_validare): # functia de validare a datelor de intrare if len(numere_validare) > 50: fisier_iesire_validare.write("Datele introduse nu corespund restrictiilor impuse\n") exit(0) for numar in numere_validare: if len(str(numar)) > 500: # fiecare numar trebuie sa aiba mai putin de 500 de cifre fisier_iesire_validare.write("Datele introduse nu corespund restrictiilor impuse\n") exit(0) fisier_iesire_validare.write("Datele introduse corespund restrictiilor impuse\n") def scrie_bucati_patrate(numere_scriere, fisier_iesire_scriere): for numar in numere_scriere: if este_patrat_perfect(numar): fisier_iesire_scriere.write(str(numar) + '\n') def citeste_date_intrare(): with open('nanoin.txt', 'r') as fisier_intrare_citire: n_citire = int(fisier_intrare_citire.readline()) numere_citire = [] for _ in range(n_citire): fisier_intrare_citire.readline() # citim si ignoram numarul de cifre linie = fisier_intrare_citire.readline() if not linie: # daca am ajuns la sfarsitul fisierului sau exista o linie goala, iesim din bucla break numere_citire.append(int(linie)) # citim numarul return n_citire, numere_citire if __name__ == '__main__': n_main, numere_main = citeste_date_intrare() with open('nanoout.txt', 'w') as fisier_iesire_main: validare(numere_main, fisier_iesire_main) # validam datele de intrare scrie_bucati_patrate(numere_main, fisier_iesire_main) </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