300168: CF36B. Fractal

Memory Limit:64 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Fractal

题意翻译

**题目背景** 自从著名的柏林抽象主义者卡莱维奇听说分形后,他就把分形作为自己油画的主题。每天早上,他拿着一张绘图纸,开始制作他未来画布的模型。 ## 题目描述 给出染色正方形的边长n,并给出染色的方法,执行k次操作(即正方形图纸的边长为n^k),每次操作将图放大,按给出的方法将图涂黑,下一步再将图中的每块白色正方形部分按给出的方法染黑 ## 输入输出格式 **输入格式:** 第一行包括两个数字n和k(2<=n<=3,1<=k<=5), 接下来第二行到第n+1行输入染色的方法 **输出格式:** 输出一个边长为n^k的正方形,即最后染色完的画,白色格输出' . ',黑色格输出' * '

题目背景

注意这题要加上这个: ``` freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); ```

题目描述

Ever since Kalevitch, a famous Berland abstractionist, heard of fractals, he made them the main topic of his canvases. Every morning the artist takes a piece of graph paper and starts with making a model of his future canvas. He takes a square as big as $ n×n $ squares and paints some of them black. Then he takes a clean square piece of paper and paints the fractal using the following algorithm: Step 1. The paper is divided into $ n^{2} $ identical squares and some of them are painted black according to the model. Step 2. Every square that remains white is divided into $ n^{2} $ smaller squares and some of them are painted black according to the model. Every following step repeats step 2. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF36B/e8422806af6330609da67545ef59f385e8f81169.png)Unfortunately, this tiresome work demands too much time from the painting genius. Kalevitch has been dreaming of making the process automatic to move to making 3D or even 4D fractals.

输入输出格式

输入格式


The first line contains integers $ n $ and $ k $ ( $ 2<=n<=3 $ , $ 1<=k<=5 $ ), where $ k $ is the amount of steps of the algorithm. Each of the following $ n $ lines contains $ n $ symbols that determine the model. Symbol «.» stands for a white square, whereas «\*» stands for a black one. It is guaranteed that the model has at least one white square.

输出格式


Output a matrix $ n^{k}×n^{k} $ which is what a picture should look like after $ k $ steps of the algorithm.

输入输出样例

输入样例 #1

2 3
.*
..

输出样例 #1

.*******
..******
.*.*****
....****
.***.***
..**..**
.*.*.*.*
........

输入样例 #2

3 2
.*.
***
.*.

输出样例 #2

.*.***.*.
*********
.*.***.*.
*********
*********
*********
.*.***.*.
*********
.*.***.*.

Input

题意翻译

**题目背景** 自从著名的柏林抽象主义者卡莱维奇听说分形后,他就把分形作为自己油画的主题。每天早上,他拿着一张绘图纸,开始制作他未来画布的模型。 ## 题目描述 给出染色正方形的边长n,并给出染色的方法,执行k次操作(即正方形图纸的边长为n^k),每次操作将图放大,按给出的方法将图涂黑,下一步再将图中的每块白色正方形部分按给出的方法染黑 ## 输入输出格式 **输入格式:** 第一行包括两个数字n和k(2<=n<=3,1<=k<=5), 接下来第二行到第n+1行输入染色的方法 **输出格式:** 输出一个边长为n^k的正方形,即最后染色完的画,白色格输出' . ',黑色格输出' * '

加入题单

上一题 下一题 算法标签: