TheRoundCityDiv1
SRM 734 · 2018-05-16 · by Vasyl[alphacom]
Problem Statement
John and Brus are wondering how many houses are visible from the city center. A house is visible if and only if there are no other houses on the line segment connecting the house and the city center. (For the purpose of this definition, each house is a single point.)
You are given the
Constraints
- r will be between 1 and 1,000,000, inclusive.
1 Returns: 4
There are four houses in the city: at (0, 1), (0, -1), (1, 0), and (-1, 0). All four of them are visible from the city center.
2 Returns: 8
There are twelve houses in the city: (0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1), (0, 2), (0, -2), (2, 0), (-2, 0), The last four are not visible from the city center. For example, (0, 2) is not visible because (0, 1) is on the line segment from (0, 2) to the city center.
3 Returns: 16
There are twenty-eight houses in the city: (0, 1), (0, -1), (1, 0), (-1, 0), (0, 2), (0, -2), (2, 0), (-2, 0), (1, 1), (1, -1), (-1, 1), (-1, -1), (0, 3), (0, -3), (3, 0), (-3, 0), (1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1), (2, 2), (2, -2), (-2, 2), (-2, -2). Twelve of them: (0, 2), (0, -2), (2, 0), (-2, 0), (0, 3), (0, -3), (3, 0), (-3, 0), (2, 2), (2, -2), (-2, 2), (-2, -2) are not visible from the city center.
47 Returns: 4176
96 Returns: 17592
Submissions are judged against all 75 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TheRoundCityDiv1 with a public method long long find(int r) · 75 test cases · 2 s / 256 MB per case