Darts
InterviewTime limit1sMemory limit256 MB
For each dart throw coordinate, determine the score based on concentric circle radius bands and sum the scores per test case.
- Level
Easy3 of 10
- Topics
- Math, Implementation, Simulation
- Solved
- No attempts yet
Problem
Consider a game in which darts are thrown at a board. The board consists of 10 circles centered at the origin, with radii 20, 40, 60, 80, 100, 120, 140, 160, 180, and 200 (measured in millimeters). Each throw is scored according to where the dart lands. A throw earns p points (p ∈ {1, 2, …, 10}) if the smallest circle that encloses the hit point, or passes through it, has radius 20 · (11 − p). A throw that lands outside the largest circle earns no points.
Compute the total score of a series of n throws.
Input
The first line contains the number of test cases T. The test cases follow.
Each test case begins with a line containing the number of throws n (1 ≤ n ≤ 10^6). Each of the next n lines contains two integers x and y (−200 ≤ x, y ≤ 200), separated by a space — the coordinates of the point hit by one throw.
Output
For each test case, print the answer on its own line, in the order the test cases appear in the input. Each line contains a single integer — the sum of the scores of that test case's n throws.