2025-09-20 20:00:07 +09:00

23 lines
550 B
Python

import sys
input = sys.stdin.readline
def pow_dist(x1, y1, x2, y2) :
return (x1-x2)**2 + (y1-y2)**2
for _ in range(int(input())) :
x1, y1, x2, y2 = map(int, input().split())
count = 0
for _ in range(int(input())) :
cx, cy, cr = map(int, input().split())
dist1 = pow_dist(x1,y1,cx,cy)
dist2 = pow_dist(x2,y2,cx,cy)
pow_cr = cr**2
if pow_cr > dist1 and pow_cr > dist2 :
pass
elif pow_cr > dist1 or pow_cr > dist2 :
count += 1
print(count)