ZHUNT - Editorial

Zombie Hunter - EDITORIAL:

Practice

Contest

Author and Editorialist: kishen1912000

DIFFICULTY:

Cakewalk

PROBLEM:

Given coordinates of N points on the 2-D Cartesian plane, find the number of points which are at most D distance away from the origin.

EXPLANATION:

This is a straight-forward implementation based question. Compute the distances for each point from the origin and check if it is less than or equal to D. Return the count of such points.

SOLUTION:

Setter's Solution
n,d = [int(s) for s in input().split()]
l = [[int(s) for s in input().split()] for j in range(n)]
l1 = [i[0]*i[0] + i[1]*i[1] for i in l]
ans = 0
for i in range(n):
    if l1[i]<=d*d:
        ans += 1
print(ans)