RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
ICPC00010

J. Pyramids

Unrated 레이팅 미적용
난이도
3s
시간 제한
1024MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

It is not too hard to build a pyramid if you have a lot of identical cubes. On a flat foundation you lay, say, \(10 \times 10\) cubes in a square. Centered on top of that square you lay a \(9 \times 9\) square of cubes. Continuing this way you end up with a single cube, which is the top of the pyramid. The height of such a pyramid equals the length of its base, which in this case is 10. We call this a high pyramid. If you think that a high pyramid is too steep, you can proceed as follows. On the \(10 \times 10\) base square, lay an \(8 \times 8\) square, then a \(6 \times 6\) square, and so on, ending with a \(2 \times 2\) top square (if you start with a base of odd length, you end up with a single cube on top, of course). The height of this pyramid is about half the length of its base. We call this a low pyramid. Once upon a time (quite a long time ago, actually) there was a pharaoh who inherited a large number of stone cubes from his father. He ordered his architect to use all of these cubes to build a pyramid, not leaving a single one unused. The architect kindly explained that not every number of cubes can form a pyramid. With 10 cubes you can build a low pyramid with base 3. With 5 cubes you can build a high pyramid of base 2. But no pyramid can be built using exactly 7 cubes. The pharaoh was not amused, but after some thinking he came up with new restrictions. 1. All cubes must be used. 2. You may build more than one pyramid, but you must build as few pyramids as possible. 3. All pyramids must be different. 4. Each pyramid must have a height of at least 2. 5. Satisfying the above, the largest of the pyramids must be as large as possible (i.e., containing the most cubes). 6. Satisfying the above, the ne\(xt-to-la\)rgest pyramid must be as large as possible. 7. And so on... Drawing figures and pictures in the sand, it took the architect quite some time to come up with the best solution. Write a program that determines how to meet the restrictions of the pharaoh, given the number of cubes.

제약
입력 형식

The input consists of several test cases, each one on a single line. A test case is an integer \(c\), where \(1 \le c \le 10^{6}\), giving the number of cubes available. The last test case is followed by a line containing a single zero.

출력 형식

For each test case, display its case number followed by the pyramids to be built. The pyramids should be ordered with the largest first. Pyramids are specified by the length of their base followed by an L for low pyramids or an H for high pyramids. If two differenct pyramids have the same number of cubes, list the high pyramid first. Print “impossible” if it is not possible to meet the requirements of the pharaoh. Follow the format of the sample output.

예제 1
입력
29
28
0
ICPC 2011 World Finals Problem J: Pyramids
출력
Case 1: 3H 3L 2H
Case 2: impossible
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC World Finals 2011

평가 및 의견

J. Pyramids

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

J. Pyramids

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8