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
2141 - Exp
(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" line="1"> def respecta_restrictiile(m, n, xi): if not (0 < n < 5000): print("Eroare: Numărul de elemente n trebuie să fie între 0 și 5000.") return False if not (0 < m < 5): print("Eroare: Numărul m trebuie să fie una din cifrele 2, 3, 4.") return False if not all(0 < x < 30001 for x in xi): print("Eroare: Elementele xi trebuie să fie în intervalul (0, 30001).") return False return True def este_numar_natural(n): return n == int(n) and n > 0 def descompunere_in_factori_primi(numar): factori_primi = [] divizor = 2 while divizor <= numar: putere = 0 while numar % divizor == 0: numar //= divizor putere += 1 if putere > 0: factori_primi.append((divizor, putere)) divizor += 1 return factori_primi def main(): with open("expIN.txt", "r") as f: m = int(f.readline().strip()) n = int(f.readline().strip()) xi = list(map(int, f.readline().split())) if not respecta_restrictiile(m, n, xi): return # Restul codului pentru calcule și scrierea în fișier rămâne neschimbat produs = 1 for x in xi: produs *= x radical_m = produs ** (1/m) with open("expOUT.txt", "w") as f: if este_numar_natural(radical_m): f.write("1\n") factori_primi = descompunere_in_factori_primi(int(radical_m)) for factor, putere in factori_primi: f.write(f"{factor} {putere}\n") else: f.write("0\n") if __name__ == "__main__": 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