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
2241 - Inspectorat
(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"> # 2241 - Inspectorat import math def valideaza_datele_intrare(n, perechi): """ Verifică dacă datele de intrare sunt valide. Verifică dacă numărul de perechi este egal cu n și dacă toate numerele din perechi sunt întregi și pozitive. """ if len(perechi) != n: print("Datele nu corespund restricțiilor impuse.") exit(0) for x, y in perechi: if not isinstance(x, int) or not isinstance(y, int) or x <= 1 or y <= 1 or x > 200000 or y > 200000: print("Datele nu corespund restricțiilor impuse.") exit(0) print("Datele sunt introduse corect.") def calculeaza_numar_prime_cu_phi(n): """ Calculează numărul de numere nenule strict mai mici decât produsul x * y care sunt prime cu x * y. """ produs = n[0] * n[1] result = produs d = 2 while d * d <= produs: if produs % d == 0: while produs % d == 0: produs //= d result = result // d * (d - 1) d += 1 if produs > 1: result = result // produs * (produs - 1) return result if __name__ == '__main__': try: n = int(input("Introduceți numărul de perechi: ")) perechi = [] for i in range(n): x, y = map(int, input(f"Introduceți perechea {i+1}: ").split()) perechi.append((x, y)) valideaza_datele_intrare(n, perechi) for pereche in perechi: count = calculeaza_numar_prime_cu_phi(pereche) print(f"Numărul de numere nenule strict mai mici decât produsul {pereche[0]} * {pereche[1]} care sunt prime cu {pereche[0]} * {pereche[1]} este: {count}") except ValueError: print("Datele nu corespund restricțiilor impuse.") exit(0) </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