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
1936 - Catalin si codul secret
(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!
= Exemplul 1: = <code>codsecretIN.txt</code> 9 2 12 6 3 10 2 4 8 3 <code>codsecretOUT.txt</code> 3 8 3 === Explicație === Numărul <code>12</code> are <code>2</code> vecini, care sunt divizori ai săi deci vom șterge tripletul <code>2 12 6</code>. Noul cod obținut este <code>3 10 2 4 8 3</code>. În noul cod avem numărul <code>2</code>, care are ca vecini doi multipli de-ai săi, deci vom șterge tripletul <code>10 2 4</code>. Noul cod obținut este <code>3 8 3</code>, căruia nu îi putem face modificări, așa că îl afișăm. == Exemplul 2: == <code>codsecretIN.txt</code> 100001 2 12 6 3 10 2 4 8 3 <code>codsecretOUT.txt</code> Datele nu corespund restrictiilor impuse == Rezolvare == <syntaxhighlight lang="python3" line="1"> import sys def conditie(a, b, c): return (b % a == 0 or a % b == 0) and (b % c == 0 or c % b == 0) def verifica_restrictii(n, numere): if not (1 <= n <= 100000) or any(x <= 0 or x > 10000000 for x in numere): print("Datele nu corespund restrictiilor impuse") sys.exit() # Încheie executia programului def citire(): global v, k n = int(input()) numere = list(map(int, input().split())) verifica_restrictii(n, numere) # Verificăm restricțiile pentru datele de intrare v = [] k = 0 for x in numere: v.append(x) k += 1 if k >= 3 and conditie(v[k - 3], v[k - 2], v[k - 1]): k -= 3 v = v[:-3] def rezolva(): if k <= 0: print("Crăciun Fericit") else: for i in range(k): print(v[i], end=" ") def main(): sys.stdin = open("codsecretIN.txt", "r", encoding='utf-8') sys.stdout = open("codsecretOUT.txt", "w", encoding='utf-8') citire() rezolva() 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