#P10458. Box Fractal Drawing
Box Fractal Drawing
Box Fractal Drawing
A fractal is an object or quantity that displays self-similarity, on all scales. The box fractal is defined recursively as follows:
- A box fractal of degree \(1\) is simply
X
. - A box fractal of degree \(2\) is:
X X X X X
For \(n \ge 2\), if we denote by \(B(n-1)\) the box fractal of degree \(n-1\), then the box fractal of degree \(n\) is constructed as:
B(n-1) B(n-1) B(n-1) B(n-1) B(n-1)
Your task is to draw the box fractal of degree \(n\) following the recursive definition above. Note that while the blocks may not be aligned width‐wise when trailing spaces are removed, the relative structure should conform to the definition.
inputFormat
The input consists of a single integer \(n\) (\(1 \le n \le 5\) for example), indicating the degree of the fractal.
outputFormat
Output the box fractal of degree \(n\) exactly as described. For degree \(1\), output X
. For higher degrees, use the recursive construction. Note that trailing spaces on each line may be omitted.
sample
1
X