Logo
(追記) (追記ここまで)

31300번 - Two Rectangles 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB24219.091%

문제

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 $m$ and $n$ is $m \cdot n,ドル and its perimeter is 2ドル \cdot (m + n)$.

Given an integer $s \ge 2,ドル consider two rectangles with positive integer lengths of sides such that the sum of their areas is $s$. What is the minimum possible sum of their perimeters?

Formally, choose four positive side lengths $a,ドル $b,ドル $c$ and $d$ so that the total area $a \cdot b + c \cdot d$ equals $s$ and the total perimeter 2ドル \cdot (a + b) + 2 \cdot (c + d)$ is minimum possible.

입력

The first line of input contains one integer $s$ (2ドル \le s \le 10^{18}$).

출력

On the first line, print one number: the minimum possible total perimeter. On the second line, print $a$ and $b,ドル the side lengths of the first rectangle, separated by a space. On the third line, print $c$ and $d,ドル 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.

제한

예제 입력 1

5

예제 출력 1

12
1 1
2 2

예제 입력 2

8

예제 출력 2

16
3 2
1 2

힌트

In the first example, the only optimal answer is to choose squares of sizes 1ドル \times 1$ and 2ドル \times 2$. They can be printed in any order.

In the second example, there is another optimal answer: instead of rectangles 1ドル \times 2$ and 2ドル \times 3,ドル we can choose two squares of size 2ドル \times 2$ each.

출처

Contest > Open Cup > 2014/2015 Season > Stage 1: Grand Prix of SPb J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /