import math
SIMPSON_ESP = 10 ** (-8)
n = int(input())
circles = []
for _ in range(n):
x, y, r = map(int, input().split())
circles.append((x, y, r))
# 被积函数, 求扫描线x和所有圆相交部分的并集的长度
from functools import lru_cache
@lru_cache(typed=False, maxsize=99999999999)
def f(x):
rr = []
for x_val, y_val, r_val in circles:
if x <= x_val-r_val or x >= x_val+r_val:
continue
y_delta = math.sqrt(r_val**2 - (x-x_val)**2)
rr.append((y_val - y_delta, y_val + y_delta))
# 区间合并
rr.sort()
tot = 0
max_end = -0x7fffffff # 当前已经枚举过的区间的结尾的最大值
for a, b in rr:
if a <= max_end:
if b > max_end:
tot += b - max_end
max_end = b
else:
tot += b - a
max_end = b
return tot
# 普通simpson积分估值函数, func是被积函数,a, b是积分区间
def __simpson(func, a, b):
return (func(a) + 4*func((a+b)/2) + func(b)) * (b-a) / 6
# 自适应simpson积分
def adaptive_simpson(func, a, b):
mid = (a + b) / 2
val, val1, val2 = __simpson(func, a, b), __simpson(func, a, mid), __simpson(func, mid, b)
if abs(val - val1 - val2) < SIMPSON_ESP:
return val1 + val2
return adaptive_simpson(func, a, mid) + adaptive_simpson(func, mid, b)
print("%0.3f" % adaptive_simpson(f, -2100, 2100))