-242. Three Circles

I'm a slow walker, but I never walk backwards.

題目來源:judgegirl from ntu prof. pangfeng Liu

Task Description

You are given three circles, , and . The center of is at , and its radius is . The centers and radius of and are defined similarly. A point is within a circle if its distance is less than or equal to the radius of the circle. For example, Both and are within the circle that centered at and has radius 1. Now given the centers and radius of the three circles, please find the number of points where both , and are integers, that are within odd number of circles. Note that the circles can overlap arbitrarily, however, the radius is no more than 10. As a result you must be careful about how to test points, so that your program will run fast, and without doing unnecessary testing.

Input format

The first line of the input is the number of input cases. Each input case has three lines and each line has the , , coordinates of a circle, followed by the radius. The radius is no more than 10.

Output format

For each test case output the number of points where both , and are integers, that are within odd number of circles.

Sample input

2
0 0 1
0 0 2
2 0 1
0 0 1
1000000 0 1
0 1000000 1

Sample output

11
15

Submit

Login

Testdata Set

Download Testdata