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
2024 - Divizor 112
(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 get_prime_factors(num): factors = {} divisor = 2 while num > 1: while num % divisor == 0: num //= divisor factors[divisor] = factors.get(divisor, 0) + 1 divisor += 1 return factors def find_max_divisor(nums): prime_factors_count = {} max_divisor = None max_count = 0 for num in nums: factors = get_prime_factors(num) for factor, count in factors.items(): prime_factors_count[factor] = max(prime_factors_count.get(factor, 0), count) for factor, count in prime_factors_count.items(): if count > max_count: max_count = count max_divisor = factor return max_divisor def verifica_restrictii(input_file, output_file): # Citire date de intrare with open(input_file, "r") as f: n = int(f.readline()) numbers = list(map(int, f.readline().split())) # Apelare funcție de rezolvare result = find_max_divisor(numbers) # Verificare restricții if 1 <= n <= 100000 and all(1 <= num < 1000000 for num in numbers): # Citire rezultat așteptat with open(output_file, "r") as g: result_asteptat = int(g.readline().strip()) # Verificare rezultat if result == result_asteptat: print("Rezultat corect!") else: print("Rezultat incorect!") print("Rezultat așteptat:", result_asteptat) print("Rezultat obținut:", result) else: print("Date de intrare nevalide!") # Citire date de intrare with open("divizor112in.txt", "r") as f: n = int(f.readline()) numbers = list(map(int, f.readline().split())) # Apelare funcție de rezolvare result = find_max_divisor(numbers) # Scriere date de ieșire with open("divizor112out.txt", "w") as g: g.write(str(result) + "\n") # Apelare funcție de verificare verifica_restrictii("divizor112in.txt", "divizor112out.txt") </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