本站作为LDUOnlineJudge的测试版本进行演示,官方网站请访问http://icpc.ldu.edu.cn
[Hidden]

1247. F. Sierpinski Triangle


Description

The SierpiMski triangle is a beautiful fractal found in mathematics.  As with many fractal patterns, it is constructed by starting with a given shape, applying a function to that shape, then applying the same function to the resulting shapes, and so on.  In theory, this function is applied infinitely many times, but in practice it usually stops after a given number of applications since the resulting shapes get too small to be noticeable.


The SierpiMski triangle is created with the following steps:
 
1) Start with an equilateral triangle with the base parallel to the horizontal axis.

2) Create an upside down triangle with half the height and width of the original triangle and cut this pattern out of the center of the original triangle, leaving 3 equilateral triangles.
3) Repeat step 2 on each of the newly formed triangles.

The following image (from Wikipedia) shows triangles of level 1 through 5, respectively

Interestingly enough, there are other shapes to which you can apply a similar pattern that result in close approximations of a SierpiMski triangle.  For example, starting with a square, you can remove rectangles of half the height and a quarter of the width from the upper left and right corners, resulting in three new squares. The following image (from Wikipedia) shows approximate triangles of level 1 through 5, respectively:

 
  

Input

The input will begin with a positive integer T representing the number of triangles to draw. This will be followed by T lines each with a positive integer K<=10 representing the level of the triangle you are to draw.

Output

Samples

Input Copy
2
1
4
Output
Triangle #1:
XX
XX

Triangle #2:
       XX       
       XX       
      XXXX      
      XXXX      
     XX  XX     
     XX  XX     
    XXXXXXXX    
    XXXXXXXX    
   XX      XX   
   XX      XX   
  XXXX    XXXX  
  XXXX    XXXX  
 XX  XX  XX  XX 
 XX  XX  XX  XX 
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX

Source

UCF2014 PRACTICE
Problem Information

Time Limit: 1000MS (C/C++,Others×2)
Memory Limit: 128MB (C/C++,Others×2)
Special Judge: No
AC/Submit: 1 / 1
Tags:
Contests involved

1028. UCF 2014 Practice
My history solutions

You didn't submit any solution!
Submit your solution

Login Register