This page is still under construction.

Parts of this page are still being built. What you see may change.

Subdividing a Land

Time limit8sMemory limit512 MB

Summary
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 aa meters. The complex contains nn subdivided blocks, each of which is a bb-meter square. Here both aa and bb 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 aa and bb among those which produce the minimum dead space for given nn.

Input

The input consists of multiple test cases. Each test case comes in a line, which contains an integer nn. You may assume 1≤n≤100001 \le n \le 10000.

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 aa and bb as in the sample output.

You may assume both aa and bb fit into 64-bit signed integers.

Examples1

  1. Example 1

    Input
    1
    2
    0
    
    Expected output
    Case 1: 3 2
    Case 2: 2 1