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
1422 - Ograda
(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> # Verificăm dacă toate valorile de intrare respectă restricțiile def validare_date(C, P, X): if not (isinstance(C, int) and isinstance(P, int) and isinstance(X, int)): return False if not (0 < C <= 200000000000 and 0 < P <= 200000000000): if X == 1: return False elif not (0 < C <= 50000000 and 0 < P <= 50000000): return False if not (2 * C <= P <= 4 * C and P % 2 == 0): return False return True if __name__ == "__main__": # Citire date de intrare with open("ograda.in", "r") as f: X = int(f.readline()) C, P = map(int, f.readline().split()) # Verificare validare date if validare_date(C, P, X): with open("ograda.out", "w") as f_out: f_out.write("Datele sunt introduse corect.\n") # Rezolvare cerinta 1 if X == 1: # Numarul total de capete t = C # Numarul total de picioare l = P # Numarul de gaini (cu 2 picioare si 1 cap) g = (4*t - l) // 2 # Numarul de vacute (cu 4 picioare si 1 cap) v = t - g # Afisare rezultat with open("ograda.out", "a") as f_out: f_out.write(str(g) + " " + str(v)) # Rezolvare cerinta 2 elif X == 2: # Numarul de divizori impari pentru numarul C d1 = 1 for i in range(3, C+1, 2): if C % i == 0: d1 += 1 # Numarul de divizori pari pentru numarul P d2 = 1 for i in range(2, P+1, 2): if P % i == 0: d2 += 1 # Afisare rezultat with open("ograda.out", "a") as f_out: f_out.write(str(d1) + " " + str(d2)) else: with open("ograda.out", "w") as f_out: f_out.write("Datele nu corespund restricțiilor impuse.") </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