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
2446 - Numere 24
(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_numar(numar, limit): if not numar.isdigit(): return False if int(numar) < 0 or int(numar) > limit: return False return True def validare_numere(n, x, k, c): if c == 1: return validare_numar(n, 2000000000) elif c == 2: return all(validare_numar(numar, 2000000000) for numar in [x]) elif c == 3: return validare_numar(k, 50) return False def constr_sir(): sir = [str(i) for i in range(10)] for i in range(1, 10): sir.append(str(i * 10 + i)) for i in range(1, 100): for j in range(10): s = str(i) + str(j) + str(i)[::-1] sir.append(s) return sir def cerinta_1(n): sir = constr_sir() numere_eliminate = [] i = 0 while len(numere_eliminate) < n: if sir[i] not in numere_eliminate and sir[i] != sir[i][::-1]: numere_eliminate.append(sir[i]) sir[i] = sir[i][:-1] else: i += 1 return numere_eliminate[-1] def cerinta_2(x): sir = constr_sir() counts = [0, 0, 0] for i in range(len(sir)): if sir[i][-1] == x: counts[0] += 1 if len(sir[i]) >= 2 and sir[i][-2] == x // 10: counts[1] += 1 if len(sir[i]) >= 3 and sir[i][-3] == x // 100: counts[2] += 1 return counts def cerinta_3(k): sir = constr_sir() count = 0 for num in sir: if len(num) == k: count += 1 elif len(num) > k: break return count if __name__ == '__main__': with open('numere24.in', 'r') as f: c = int(f.readline().strip()) n, x, k = map(int, f.readline().split()) if validare_numere(n, x, k, c): print("Datele sunt introduse corect.") if c == 1: result = cerinta_1(n) with open('numere24.out', 'w') as f: f.write(str(result) + '\n') elif c == 2: counts = cerinta_2(x) with open('numere24.out', 'w') as f: f.write(' '.join(map(str, counts)) + '\n') elif c == 3: count = cerinta_3(k) with open('numere24.out', 'w') as f: f.write(str(count) + '\n') else: print("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