110. Pyramid

Codeforces
IDCF10269110
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Much like the previous question, you are going to be making some ASCII art. In this question your job is to make a pyramid given a number that represents the base of the pyramid. Each layer going up from the base should be 2 less in length than the previous layer. The pyramid is complete when the length of the top layer is either 1 or 2. A single number representing the base of the pyramid. Print the pyramid using "X"'s Don't forget to add spacing on the left side so that it doesn't end up looking like a right triangle. ## Input A single number representing the base of the pyramid. ## Output Print the pyramid using "X"'s [samples] ## Note Don't forget to add spacing on the left side so that it doesn't end up looking like a right triangle.
**Definitions** Let $ n \in \mathbb{Z}^+ $ denote the base width of the pyramid. **Constraints** $ n \geq 1 $, and $ n $ is odd or even; the pyramid terminates when the top layer has width 1 or 2. **Objective** Construct a pyramid with layers $ k = 0, 1, \dots, m-1 $, where: - Layer $ k $ has width $ w_k = n - 2k $, - The pyramid stops when $ w_k \in \{1, 2\} $, - Each layer is centered by prepending $ \left\lfloor \frac{n - w_k}{2} \right\rfloor $ spaces, - Each layer is composed of $ w_k $ characters 'X'. Output the pyramid as a sequence of strings, one per layer, from bottom to top.
API Response (JSON)
{
  "problem": {
    "name": "110. Pyramid",
    "description": {
      "content": "Much like the previous question, you are going to be making some ASCII art. In this question your job is to make a pyramid given a number that represents the base of the pyramid. Each layer going up f",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269110"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Much like the previous question, you are going to be making some ASCII art. In this question your job is to make a pyramid given a number that represents the base of the pyramid. Each layer going up f...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ denote the base width of the pyramid.  \n\n**Constraints**  \n$ n \\geq 1 $, and $ n $ is odd or even; the pyramid terminates when the top layer has width 1 or...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments