Two Rectangles
시간 제한2초메모리 제한1024 MB
총넓이가 s인 두 직사각형의 변을 양의 정수로 정할 때 두 둘레의 합이 최소가 되는 값을 구한다.
문제
In this problem, you have to find two rectangles with the given total area which have the minimum possible total perimeter.
Recall that the area of a rectangle having sides of length and is , and its perimeter is .
Given an integer , consider two rectangles with positive integer lengths of sides such that the sum of their areas is . What is the minimum possible sum of their perimeters?
Formally, choose four positive side lengths , , and so that the total area equals and the total perimeter is minimum possible.
입력
The first line of input contains one integer ().
출력
On the first line, print one number: the minimum possible total perimeter. On the second line, print and , the side lengths of the first rectangle, separated by a space. On the third line, print and , the side lengths of the second rectangle, also separated by a space. If there is more than one possible answer, print any one of them.
힌트
In the first example, the only optimal answer is to choose squares of sizes and . They can be printed in any order.
In the second example, there is another optimal answer: instead of rectangles and , we can choose two squares of size each.