Repeater Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4187 Accepted: 1114 Description Harmony is indispensible in our daily lifeand no one can live without it----may be Facer is the only exception. One dayit is rumored that repeat painting will create harmony and then hundreds ofpeople started their endless drawing. Their paintings were based on a smalltemplate and a simple method of duplicating. Though Facer can easily imaginethe style of the whole picture, but he cannot find the essential harmony. Nowyou need to help Facer by showing the picture on computer. You will be given a template containingonly one kind of character and spaces, and the template shows how the endlesspicture is created----use the characters as basic elements and put them in theright position to form a bigger template, and then repeat and repeat doingthat. Here is an example.
# # # <-template # # So the Level 1 picture will be
# # # # # Level 2 picture will be
# # ## # # # # ## ## # ## # # ## # # # # ##
Input The input contains multiple test cases. Thefirst line of each case is an integer N, representing the size of the template is N*N (N could only be 3, 4 or 5). Next Nlines describe the template. Thefollowing line contains an integer Q, which is the Scale Level of the picture. Inputis ended with a case of N=0. It isguaranteed that the size of one picture will not exceed 3000*3000. Output For each test case, just print the Level Q picture by using the given template.
Sample Input 3 # # # # # 1 3 # # # # # 3 4 OO O O O O OO 2 0 Sample Output # # # # # # # ## ## ## # # # # # # ## ## ## ## ## # # ## ## # # ## ## ## # # # # # # ## ## ## ## ## # # ## ## ## # ## ## ## # # ## ## # # ## ## ## # # # # # # ## ## ## ## ## # # ## ## # # ## ## ## # # # # # # ## ## ## OO OO O OO O O OO O OO OO OO OO O O O O O O O O OO OO OO OO O O O O O O O O OO OO OO OO O OO O O OO O OO OO
本题就是一个基础的分形问题 ,只不过是在一个自己定义的图形中,再进行分形处理 。 所以我们一定要把最先定义的图形遍历一遍 找到他的基础结构。用一个二维的数组标记出他的最基础构型 ,就可以开始分型了。 稍有不同的是在分形打印的函数中的递归函数需要双层的 for 循环来遍历标记数组, 其实在遍历标记数组的时候发现比把每个都写出来要容易操作的多(但时间复杂度会变高),当然本题必须采用遍历的操作才可以,因为自己定义的图形,在没有定义的时候,他的结构就是未知的,所以必须遍历。