#abc339b. B - Langton's Takahashi
B - Langton's Takahashi
Score: points
问题描述
存在一个 行和 列的网格;最初,所有单元格都被涂成白色。令 表示从上到下的第 行以及从左到右的第 列的单元格。
这个网格被认为是环面的。也就是说,对于每个 , 在 的右侧,并且对于每个 , 在 的下方。
高桥位于 处并面向上方。在高桥重复执行以下操作 次后,打印网格中每个单元格的颜色。
- 如果当前单元格被涂成白色,则将其重新涂成黑色,顺时针旋转 ,然后按照他面对的方向向前移动一格。否则,将当前单元格重新涂成白色,逆时针旋转 ,然后按照他面对的方向向前移动一格。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a grid with rows and columns; initially, all cells are painted white. Let denote the cell at the -th row from the top and the -th column from the left.
This grid is considered to be toroidal. That is, is to the right of for each , and is below for each .
Takahashi is at and facing upwards. Print the color of each cell in the grid after Takahashi repeats the following operation times.
- If the current cell is painted white, repaint it black, rotate clockwise, and move forward one cell in the direction he is facing. Otherwise, repaint the current cell white, rotate counterclockwise, and move forward one cell in the direction he is facing.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain a string of length where the -th character is .
if the cell is painted white, and #
if it is painted black.
Sample Input 1
3 4 5
Sample Output 1
.#..
##..
....
The cells of the grid change as follows due to the operations:
.... #... ##.. ##.. ##.. .#..
.... → .... → .... → .#.. → ##.. → ##..
.... .... .... .... .... ....
Sample Input 2
2 2 1000
Sample Output 2
..
..
Sample Input 3
10 10 10
Sample Output 3
##........
##........
..........
..........
..........
..........
..........
..........
..........
#........#
update @ 2024/3/10 01:30:56