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
3064 - Copii 1
(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> def validare_date(c, x=None, y=None, k=None): if c not in [1, 2]: print("Datele nu corespund restricțiilor impuse.") return False if c == 1: if not (1 <= x <= 10**6 and 1 <= y <= 10**12 and 1 <= k <= 9): print("Datele nu corespund restricțiilor impuse.") return False elif c == 2: if not (1 <= y <= 10**12): print("Datele nu corespund restricțiilor impuse.") return False print("Datele sunt introduse corect.") return True def produs_ultimele_k_cifre(x, k): product = 1 for i in range(1, x+1): product *= i while product % 10 == 0: product //= 10 product %= 10**k return product def numar_divizori(n): count = 0 for i in range(1, int(n**0.5) + 1): if n % i == 0: count += 1 if i % 2 == 1 else 0 if i != n // i and (n // i) % 2 == 1: count += 1 return count if __name__ == '__main__': with open('copii.in', 'r') as fin: c = int(fin.readline().strip()) if c == 1: x = int(fin.readline().strip()) k = int(fin.readline().strip()) if not validare_date(c, x, k=k): exit() print(f"Produsul ultimelor {k} cifre ale lui {x}! este {produs_ultimele_k_cifre(x, k)}") elif c == 2: y = int(fin.readline().strip()) if not validare_date(c, y=y): exit() divizori_count = produs_ultimele_k_cifre(y) max_divizor = 1 for i in range(3, int(y**0.5) + 1, 2): while y % i == 0: max_divizor *= i y //= i if y > 2: max_divizor *= y print(f"Cel mai mare divizor al lui {y} cu un numar impar de divizori este {max_divizor} cu {divizori_count} divizori impari") with open('copii.out', 'w') as fout: if c == 1: fout.write(str(produs_ultimele_k_cifre(x, k))) elif c == 2: fout.write(f"{max_divizor} {divizori_count}") </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