a157. Present from Lena (來自 Lena 的禮物)
Tags :
Accepted rate : 1人/1人 ( 100% ) [非即時]
評分方式:
Strictly

最近更新 : 2026-02-21 14:26

Content

Vasya 的生日快到了,Lena 決定縫製一條有圖案的手帕送給他當禮物。Lena 選擇了從 0n 的數字作為圖案。這些數字將組成一個菱形(rhombus)。最大的數字 n 應位於中心位置。當數字向邊緣延伸時應逐漸遞減。

例如,當 n = 5 時,手帕的圖案應該是要長這樣:

 

          0
        0 1 0
      0 1 2 1 0
    0 1 2 3 2 1 0
  0 1 2 3 4 3 2 1 0
0 1 2 3 4 5 4 3 2 1 0
  0 1 2 3 4 3 2 1 0
    0 1 2 3 2 1 0
      0 1 2 1 0
        0 1 0
          0


您的任務是根據給定的 n 來確定手帕最終呈現的樣子。
Input

第一行包含一個整數 n (2 ≤ n ≤ 9)

Output

輸出給定 n 的圖案。您應嚴格遵守每行第一個數字前的空格數量。同一行中任意兩個相鄰數字之間應恰好由一個空格隔開。每行最後一個數字之後不應有任何空格。

Sample Input #1
2
Sample Output #1
    0
  0 1 0
0 1 2 1 0
  0 1 0
    0
Sample Input #2
3
Sample Output #2
      0
    0 1 0
  0 1 2 1 0
0 1 2 3 2 1 0
  0 1 2 1 0
    0 1 0
      0
測資資訊:
記憶體限制: 256 MB
不公開 測資點#0 (12%): 1.0s , <1K
不公開 測資點#1 (12%): 1.0s , <1K
不公開 測資點#2 (12%): 1.0s , <1K
不公開 測資點#3 (12%): 1.0s , <1K
不公開 測資點#4 (13%): 1.0s , <1K
不公開 測資點#5 (13%): 1.0s , <1K
不公開 測資點#6 (13%): 1.0s , <1K
不公開 測資點#7 (13%): 1.0s , <1K
Hint :
B. Present from Lena
time limit per test
2 seconds
memory limit per test
256 megabytes

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:


          0
        0 1 0
      0 1 2 1 0
    0 1 2 3 2 1 0
  0 1 2 3 4 3 2 1 0
0 1 2 3 4 5 4 3 2 1 0
  0 1 2 3 4 3 2 1 0
    0 1 2 3 2 1 0
      0 1 2 1 0
        0 1 0
          0

Your task is to determine the way the handkerchief will look like by the given n.

Input

The first line contains the single integer n (2 ≤ n ≤ 9).

Output

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.

Tags:
出處:
Codeforces Beta Round 89 (Div. 2) pB [管理者: 411211(誰說數學考17分不能寫程式) ]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」