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
4140 - bug
(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> #4140 bug def check_input(query, preferred_number): # Verificăm dacă query-ul este valid if query != 1 and query != 2: return "Eroare: Query-ul trebuie să fie 1 sau 2." # Verificăm dacă preferred_number este un număr natural nenul if preferred_number <= 0: return "Eroare: Numărul preferat trebuie să fie un număr natural nenul." return None def is_subsequence(number, preferred_number): number_str = str(number) preferred_str = str(preferred_number) i = 0 for digit in preferred_str: if digit == number_str[i]: i += 1 if i == len(number_str): return True return False def find_smallest_non_subsequence(preferred_number): i = 1 while True: if not is_subsequence(i, preferred_number): return i i += 1 def main(): # Citim datele de intrare with open("bug.in", "r") as f: query = int(f.readline()) preferred_number = int(f.readline()) # Verificăm datele de intrare error_message = check_input(query, preferred_number) if error_message: with open("bug.out", "w", encoding='utf-8') as f: f.write(error_message) return # Rezolvăm cerința if query == 1: smallest_non_subsequence = find_smallest_non_subsequence(preferred_number) with open("bug.out", "w", encoding='utf-8') as f: f.write(str(len(str(smallest_non_subsequence)))) else: smallest_non_subsequence = find_smallest_non_subsequence(preferred_number) with open("bug.out", "w", encoding='utf-8') as f: f.write(str(smallest_non_subsequence)) # Apelăm funcția main pentru a rezolva cerința 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