Simple Darts
InterviewTime limit1sMemory limit1024 MB
Given a circular board with w wedges and ring radii b, d, and s, sum the scores of each dart throw at (x, y) coordinates.
- Level
Easy3 of 10
- Topics
- Geometry, Implementation
- Solved
- No attempts yet
Problem

Figure 1. Standard Dartboard
Darts is a fun game that needs little physical space, so many game rooms have a board. The standard dartboard (see Figure 1) has 6 concentric rings and 20 wedges. The wedges divide the board into regions, and each region has a fixed score. Figure 1 shows fewer than 20 wedges so that the picture stays clear. The innermost ring is a double bullseye. The second ring is a single bullseye. Beyond the second ring, each wedge scores from 1 to 20. Some of the gaps between rings act as double or triple modifiers.
A simpler version of the game has been proposed to attract younger players.
Problem

Figure 2. Example Simple Dartboard
The simpler version is shown in Figure 2. The board has exactly 3 concentric rings instead of 6. It may have fewer than 20 wedges, and all wedges are the same size. The scoring works as follows.
The board is centered at the origin of the Cartesian plane. is the number of wedges (8 in Figure 2). , , and are the radii of the smallest ring, the second smallest ring, and the largest ring.
The wedge directly above the positive x axis (Wedge 1 in Figure 2) scores 1 point. Moving counterclockwise, each wedge scores 1 more than the previous one, so the wedge directly below the positive x axis (Wedge 8 in Figure 2) scores . The circle of radius around the origin is the bullseye, and it always scores 50 points. The area between radii and is the double ring. A dart there scores twice the value of the surrounding wedge. The area between radii and is the single ring. A dart there scores the value of the surrounding wedge. A dart outside the board scores 0.
Given the layout of such a board centered at the origin and a list of dart throws, calculate the total score.
Input
The first line contains a positive integer , the number of test cases.
Each test case starts with a line of four integers , , , , separated by spaces. () is the number of equal-sized wedges. , , and () are the radii of the bullseye, the double ring, and the single ring.
The next line contains (), the number of dart throws. Each of the following lines contains two real numbers and with three decimal places, where . No dart lands within of any boundary (line or arc).
Output
For each test case, print the total score of all its dart throws as a single integer on its own line.