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
2751 - BB Security
(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!
= Restricții și precizări = * <code>1 ≤ n ≤ 100.000</code>; * cele <code>n</code> numere citite vor fi mai mici decât <code>1.000.000</code>; * <code>n, l, c, h</code> sunt numere naturale; * este garantat că pentru orice triplet citit există un număr <code>0 ≤ x ≤ c</code>; * cea de-a doua zecimala se rotunjește de obicei după cea de-a treia (ex. <code>49.4376</code> se va afișa ca <code>49.44</code>); * ∀ <code>a</code>| <code>a</code> ∈ ℕ, acesta se va afișa ca <code>a.00</code> (ex. <code>50</code> se va afișa ca <code>50.00</code>); * Atenție! <code>23.455 = 23.45 , 23.45501 = 23.46</code>. == Exemplul 1 == Input: 2 60 100 20 100 50 100 Output: 49.44 50.00 Explicație: Pentru primul triplet lungimea dintre cei doi stâlpi este <code>49.44</code>, iar pentru al doilea cablul este întins la maximum și lungimea dintre cei doi stâlpi este <code>50.00</code>. == Exemplul 2 == Input: 1 34 7.2 9.1 Output: Numerele trebuie să fie naturale. == Rezolvare == <syntaxhighlight lang="python3" line="1"> import math def verifica_conditii(n, tests): results = [] for i in range(n): l, c, h = tests[i] # Verificare dacă numerele sunt naturale if not all(map(lambda x: x.is_integer() and x >= 0, [l, c, h])): results.append("Numerele trebuie să fie naturale.") continue if h == l: results.append(f"{int(c):.2f}") elif c / 2 + h == l: results.append("0.00") else: a = ((c**2 / 4) - (l - h)**2) / (2 * (l - h)) t1 = 2 * a * math.log(math.sqrt((c**2 / 4) / (a**2) + 1) + (c / 2) / a) # Rotunjirea valorilor conform specificațiilor rounded_t1 = round(t1, 2) if rounded_t1.is_integer(): results.append(f"{int(rounded_t1)}.00") else: results.append(f"{rounded_t1:.2f}") return results def main(): n = int(input()) tests = [] for _ in range(n): l, c, h = map(float, input().split()) tests.append((l, c, h)) results = verifica_conditii(n, tests) for result in results: print(result) 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