PivotOJ

Impressive Integers

시간 제한: 1000ms메모리 제한: 512MB출처: GCPC 2020BOJ 20909

문제

Recently, Alice and her sister Clara learned about adorable numbers: A positive integer nn is called adorable if there exist some integers a,b,a, b, and cc so that an equilateral triangle with side length cc can be tiled with nn smaller equilateral triangles, each having a side length of either aa or bb. For instance, 66 is an adorable number as shown in Figure I.1a below.

(a) Visualization of the second sample output. (b) Coordinate system used for the output.

They decided to see who can come up with more adorable numbers, but it turns out that checking all the numbers manually is too cumbersome. Therefore, Alice asked you to help her check whether the numbers Clara listed are adorable or not. As she wants to be sure that every number claimed to be adorable really is adorable, she asked you to write a program that, given an integer nn, determines if it is adorable and if so, outputs a valid tiling as shown in Figure I.1a.

입력

The input consists of:

  • A single positive integer nn (1n10001 \leq n \leq 1\,000).

출력

If the given integer nn is adorable, output a valid tiling using the following format:

  • Three integers a,b,ca, b, c (1a,bc1091 \leq a, b \leq c \leq 10^9), such that an equilateral triangle with side length cc can be tiled with nn equilateral triangles with side lengths aa and bb.
  • nn lines, each describing one of the triangles and consisting of:
    • one of A and B, specifying if the side length of the triangle is aa or bb;
    • two integers x,yx, y, giving the leftmost corner of the triangle;
    • one of U and D, specifying whether the triangle is pointing upwards or downwards.
    These triangles must form a valid tiling of the equilateral triangle with corners at (0,0),(0,c),(0, 0), (0, c), and (c,0)(c, 0), where all coordinates are given using the coordinate system in Figure I.1b.

Otherwise, if nn is not adorable, output impossible.

If your tiling consists of triangles that all have the same size, you may either use A or B exclusively for all of your triangles, or set a=ba = b and arbitrarily label each triangle with A or B.

It can be shown that for every adorable number in the input range it is possible to construct a tiling according to the above set of rules. You may output any valid tiling.

예제

예제 1

입력
2
출력
impossible

예제 2

입력
6
출력
1 2 3
B 0 1 U
A 0 0 U
A 0 1 D
A 1 0 U
A 1 1 D
A 2 0 U
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.