Sonechka is the best friend of Miss M. She entered the best university in the distant and progressive country of Bezchaindia. Miss M misses her friend very much, so she decided to make a gift for Sonechka while she is studying in another country.
Today is Sunny's birthday, but Miss M can still prepare the present as she has time, because Sunny will be back a little later.
Miss M decided that she wanted to learn how to cross-stitch and make ornaments on a quilt, which will be a gift for Sonechka, and give it as a present when she returns. But she still doesn't know where to start. She had the idea to write a program that would make an ornament of the desired width and length, which she could then use as an example for embroidery.
A stitch is an n×m rectangle. Ornaments are two rays that come from the upper corners of the embroidery and have angles of 45 degrees.
The ray is reflected when it touches a vertical edge. When the beam touches the lower edge, it disappears. For a better understanding, you can see examples.
Help Miss M learn how to cross-stitch and give a beautiful embroidery to the beautiful Sun for her birthday by writing the following program, which, according to the given width n and length m, will output an example of an ornament.
Incoming data
The first line contains two integers n and m (3≤n,m≤1000) — height and width, respectively.
Ответы
Ответ дал:
2
Ответ:
в кометах
Объяснение:
Вас заинтересует
2 месяца назад
2 месяца назад
2 месяца назад
2 месяца назад
1 год назад
1 год назад
7 лет назад
7 лет назад
embroidery = [['.' for _ in range(m)] for _ in range(n)]
x1, y1 = 0, 0
x2, y2 = 0, m - 1
dx1, dy1 = 1, 1
dx2, dy2 = 1, -1
while x1 < n and x2 < n:
embroidery[x1][y1] = 'x'
embroidery[x2][y2] = 'x'
if y1 == m - 1:
dx1, dy1 = 1, -1
elif y1 == 0:
dx1, dy1 = 1, 1
if y2 == m - 1:
dx2, dy2 = 1, -1
elif y2 == 0:
dx2, dy2 = 1, 1
x1, y1 = x1 + dx1, y1 + dy1
x2, y2 = x2 + dx2, y2 + dy2
for row in embroidery:
print(''.join(row))