codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

118B.md (1535B)


      1 Source: https://codeforces.com/problemset/problem/118/B
      2 
      3 B. Present from Lena
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to *n* as the pattern. The digits will form a rhombus. The largest digit *n* should be located in the centre. The digits should decrease as they approach the edges. For example, for *n* = 5 the handkerchief pattern should look like that:
     22 
     23 ```
     24           0  
     25         0 1 0  
     26       0 1 2 1 0  
     27     0 1 2 3 2 1 0  
     28   0 1 2 3 4 3 2 1 0  
     29 0 1 2 3 4 5 4 3 2 1 0  
     30   0 1 2 3 4 3 2 1 0  
     31     0 1 2 3 2 1 0  
     32       0 1 2 1 0  
     33         0 1 0  
     34           0
     35 ```
     36 
     37 Your task is to determine the way the handkerchief will look like by the given *n*.
     38 
     39 Input
     40 
     41 The first line contains the single integer *n* (2 ≤ *n* ≤ 9).
     42 
     43 Output
     44 
     45 Print a picture for the given *n*. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line.
     46 
     47 Examples
     48 
     49 Input
     50 
     51 ```
     52 2
     53 ```
     54 
     55 Output
     56 
     57 ```
     58     0  
     59   0 1 0  
     60 0 1 2 1 0  
     61   0 1 0  
     62     0
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 3
     69 ```
     70 
     71 Output
     72 
     73 ```
     74       0  
     75     0 1 0  
     76   0 1 2 1 0  
     77 0 1 2 3 2 1 0  
     78   0 1 2 1 0  
     79     0 1 0  
     80       0
     81 ```