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
2213 - Sir Div K
(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(a, b, c, n, k): # Verificăm dacă toate valorile de intrare respectă restricțiile if not(1 < n < 1000) or not(2 <= k < 32000) or not(0 <= b <= 9) or not(0 <= c <= 9) or not(1 <= a <= 9): return False else: return True if __name__ == '__main__': # Deschidem fișierul de intrare și citim valorile de intrare with open("sirdivk.in", "r") as f_in: a, b, c, n, k = map(int, f_in.readline().split()) # Verificăm dacă valorile de intrare sunt valide if not validare_date(a, b, c, n, k): # Scriem un mesaj de eroare în fișierul de ieșire și ieșim din program with open("sirdivk.out", "w") as f_out: f_out.write("Datele nu corespund restricțiilor impuse.") exit() else: # Secvența de operații pe care o vom efectua dacă valorile de intrare sunt valide numar = [a] * n for i in range(1, n): if i % 3 == 1: numar[i] = b elif i % 3 == 2: numar[i] = c rest = 0 gasite = 0 for i in range(n): rest = rest * 10 + numar[i] if rest % k == 0: gasite += 1 rest %= k # Scriem rezultatul în fișierul de ieșire with open("sirdivk.out", "w") as f_out: f_out.write("Datele sunt introduse corect.\n") f_out.write(str(gasite)) </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