#P13208. [GCJ 2016 Finals] Gallery of Pillars
[GCJ 2016 Finals] Gallery of Pillars
题目描述
Your friend Cody-Jamal is working on his new artistic installment called "Gallery of Pillars". The installment is to be exhibited in a square gallery of by meters. The gallery is divided into squares of 1 by 1 meter, forming an by matrix. The exact center of the southwest corner cell is called the viewpoint; a person viewing the artwork is supposed to stand there. Each other cell contains a cylindrical pillar. All pillars have two circular bases of radius : one resting on the floor, in the center of its corresponding cell, and the other touching the gallery's ceiling. The observer will stand in the viewpoint, observe the pillars, and marvel.
Cody-Jamal is currently scouting venues trying to see how large he can make the value of . Also, he has not decided which material the pillars will be made of; it could be concrete, or carbon nanotubes, so the radius of the base of each pillar could vary from 1 micrometer to almost half a meter. Notice that a radius of half a meter would make neighboring pillars touch.
You, as a trained mathematician, quickly observe that there could be pillars impossible to see from the viewpoint. Cody-Jamal asks your help in determining, for different combinations of and , the number of visible pillars. Formally, a pillar is visible if and only if there is a straight line segment that runs from the center of the southwest corner cell (the viewpoint) to any point on the pillar's boundary, and does not touch or intersect any other pillar.
输入格式
The first line of the input gives the number of test cases, . lines follow. Each line describes a different test case with two integers and . is the number of 1 meter square cells along either dimension of the gallery, and is the radius of each pillar, in micrometers. Thus, is the radius of each pillar in meters.
输出格式
For each test case, output one line containing Case #x: y
, where is the test case number (starting from 1) and is the number of pillars in the installment that are visible from the viewpoint.
4
4 100000
4 300000
3 300000
100 499999
Case #1: 9
Case #2: 7
Case #3: 5
Case #4: 3
提示
Sample Explanation
The pictures below illustrate the first two samples (not to scale). In the center of the black circle is the observer. The other circles are pillars, with the visible ones in gray and the not visible ones in red. The blue dotted lines represent some of the unblocked lines of sight; the red dotted lines represent blocked lines of sight (that turn gray at the point at which they are first blocked).
Limits
- .
- .
Small dataset (10 Pts, Test Set 1 - Visible)
- .
Large dataset (30 Pts, Test Set 2 - Hidden)
- .