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
3489 - Numara punctele
(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"> def validare(n: int, puncte: list[tuple[float, float]], m: int, cercuri: list[tuple[float, float, float]]) -> bool: # verificam numarul de puncte si de cercuri if not 1 <= n <= 100000 or not 1 <= m <= 10000: return False # verificam coordonatele punctelor si ale cercurilor for p in puncte: if not 0 <= p[0] <= 100 or not 0 <= p[1] <= 100: return False for c in cercuri: if not 0 <= c[0] <= 100 or not 0 <= c[1] <= 100 or c[2] <= 0: return False return True def numar_puncte_in_cercuri(puncte, cercuri): numar_puncte = [] for cerc in cercuri: num_puncte_in_cerc = 0 for punct in puncte: distanta = ((punct[0] - cerc[0]) ** 2 + (punct[1] - cerc[1]) ** 2) ** 0.5 if distanta <= cerc[2]: num_puncte_in_cerc += 1 numar_puncte.append(num_puncte_in_cerc) return numar_puncte if __name__ == "__main__": # citirea numarului de puncte n = int(input()) # citirea coordonatelor fiecarui punct puncte = [] for i in range(n): x, y = input().split() x = float(x) y = float(y) puncte.append((x, y)) # citirea numarului de cercuri m = int(input()) # citirea coordonatelor si razei fiecarui cerc cercuri = [] for i in range(m): x, y, r = input().split() x = float(x) y = float(y) r = float(r) cercuri.append((x, y, r)) # validarea datelor introduse if validare(n, puncte, m, cercuri): print("Datele introduse sunt corecte.") # numarul de puncte din interiorul fiecarui cerc numar_puncte = numar_puncte_in_cercuri(puncte, cercuri) # afisarea numarului de puncte din interiorul fiecarui cerc for i in numar_puncte: print(i) else: print("Unul sau mai multe numere introduse nu sunt valide.") </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