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
3732 - Seism
(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!
= Exemplu : = <code>seism.in</code> 1 21 0 0 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1 1 0 0 1 <code>seism.out</code> 4 === Explicație === Durata maximă a unui seism este de <code>4</code> secunde. <syntaxhighlight lang="python" line="1"> def analyze_seismic_data(signals): n = len(signals) # Durata maximă a unui seism și numărul total de seisme max_seism_duration = 0 total_seisms = 0 current_duration = 0 in_seism = False for i in range(n): if signals[i] == 1: if not in_seism and i >= 2 and signals[i-1] == 0 and signals[i-2] == 0: in_seism = True current_duration = 1 elif in_seism: current_duration += 1 else: if in_seism: if i+1 < n and signals[i+1] == 0: total_seisms += 1 max_seism_duration = max(max_seism_duration, current_duration) in_seism = False current_duration = 0 if in_seism: if n >= 2 and signals[n-1] == 0 and signals[n-2] == 0: total_seisms += 1 max_seism_duration = max(max_seism_duration, current_duration) # Durata maximă a unui seism după modificare max_seism_after_modification = 0 for i in range(n): if signals[i] == 0: modified_signals = signals[:i] + [1] * (n - i) current_duration = 0 max_duration = 0 in_seism = False for j in range(n): if modified_signals[j] == 1: if not in_seism and j >= 2 and modified_signals[j-1] == 0 and modified_signals[j-2] == 0: in_seism = True current_duration = 1 elif in_seism: current_duration += 1 else: if in_seism: if j+1 < n and modified_signals[j+1] == 0: max_duration = max(max_duration, current_duration) in_seism = False current_duration = 0 if in_seism: if n >= 2 and modified_signals[n-1] == 0 and modified_signals[n-2] == 0: max_duration = max(max_duration, current_duration) max_seism_after_modification = max(max_seism_after_modification, max_duration) return max_seism_duration, total_seisms, max_seism_after_modification # Exemplu de utilizare signals = [0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0] max_seism_duration, total_seisms, max_seism_after_modification = analyze_seismic_data(signals) print("Durata maximă a unui seism:", max_seism_duration) print("Numărul total de seisme:", total_seisms) print("Durata maximă a unui seism după modificare:", max_seism_after_modification) </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