Picture Perfect | 프로그래밍의 벗 PivotOJ
PivotOJ

Picture Perfect

시간 제한: 1000ms메모리 제한: 128MB출처: CCC 2003 JuniorBOJ 6904

문제

Roy has a stack of student yearbook photos. He wants to lay the pictures on a flat surface edge-to-edge to form a filled rectangle with minimum perimeter. All photos must be fully visible. Each picture is a square with dimensions 1 unit by 1 unit.

For example, he would place 12 photos in the following configuration, where each photo is indicated with an X.

XXXX
XXXX
XXXX

Of course, he could orient them in the other direction, such as

XXX
XXX
XXX
XXX

which would have the same perimeter, 14 units.

Your program should repeatedly read a positive integer CC, the number of pictures to be laid out. For each input, it should print the smallest possible perimeter for a filled rectangle that is formed by laying all the pictures edge-to-edge. Also print the dimensions of this rectangle.

You may assume that there are less than 6500065\,000 photos. An input value of C=0C = 0 indicates that the program should terminate.

예제

예제 1

입력
100
15
195
0
출력
Minimum perimeter is 40 with dimensions 10 x 10
Minimum perimeter is 16 with dimensions 3 x 5
Minimum perimeter is 56 with dimensions 13 x 15
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.