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
3738 - New York
(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> #3738 - New York def cmmdc_lista(lista): def cmmdc(a, b): while b: a, b = b, a % b return a result = lista[0] for elem in lista[1:]: result = cmmdc(result, elem) return result def este_prim(numar): if numar < 2: return False for i in range(2, int(numar**0.5) + 1): if numar % i == 0: return False return True def gaseste_cladire_perfecta(strazi): cmmdc_maxim = 0 strada_aleasa = 0 cladire_aleasa = 0 for i, strada in enumerate(strazi, start=1): inaltimi = strada[1:] cmmdc_strada = cmmdc_lista(inaltimi) if cmmdc_strada > cmmdc_maxim: cmmdc_maxim = cmmdc_strada strada_aleasa = i for j, inaltime in enumerate(reversed(inaltimi), start=1): if este_prim(inaltime): cladire_aleasa = len(inaltimi) - j + 1 break return strada_aleasa, cladire_aleasa try: # Citirea datelor de intrare with open('nykin.txt', 'r') as f: n = int(f.readline().strip()) strazi = [list(map(int, f.readline().split())) for _ in range(n)] # Calculul și scrierea rezultatului în fișierul de ieșire rezultat = gaseste_cladire_perfecta(strazi) with open('nykout.txt', 'w') as g: if rezultat[0] == 0: g.write("Nu am gasit casa!") else: g.write(f"{rezultat[0]} {rezultat[1]}\n{strazi[rezultat[0] - 1][rezultat[1]]}") except Exception as e: print("A aparut o eroare:", str(e)) </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