Subdividing a Land
Time limit8sMemory limit512 MB
For each n, find integer side lengths a and b minimizing the dead space above 50 percent, then the developed area, where n b-squared blocks fit in an a-squared square.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Brute force, Geometry
- Solved
- No attempts yet
Problem
Indigo Real-estate Company is planning to develop a new housing complex. The entire complex is a square, all of whose edges are equally meters. The complex contains subdivided blocks, each of which is a -meter square. Here both and are positive integers.
However the project faces a big problem. In this country, a percentage limit applies to the subdivision of a land, under the pretext of environmental protection. When developing a complex, the total area of the subdivided blocks must not exceed 50% of the area of the complex; in other words, at least 50% of the newly developed housing complex must be kept for green space. As a business, a green space exceeding 50% of the total area is a dead space. The primary concern of the project is to minimize it.
Of course purchasing and developing a land costs in proportion to its area, so the company also wants to minimize the land area to develop as the secondary concern. You, a member of the project, were assigned this task, but can no longer stand struggling against the problem with your pencil and paper. So you decided to write a program to find the pair of minimum and among those which produce the minimum dead space for given .
Input
The input consists of multiple test cases. Each test case comes in a line, which contains an integer . You may assume .
The end of input is indicated by a line containing a single zero. This line is not a part of the input and should not be processed.
Output
For each test case, output the case number starting from 1 and the pair of minimum and as in the sample output.
You may assume both and fit into 64-bit signed integers.