码迷,mamicode.com
首页 > 其他好文 > 详细

题目1161:Repeater

时间:2016-07-22 21:04:04      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

//转载于 http://blog.csdn.net/qq_24421591/article/details/51025144

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:1715

解决:618

题目描述:

Harmony is indispensible in our daily life and no one can live without it----may be Facer is the only exception. One day it is rumored that repeat painting will create harmony and then hundreds of people started their endless drawing. Their paintings were based on a small template and a simple method of duplicating. Though Facer can easily imagine the style of the whole picture, but he cannot find the essential harmony. Now you need to help Facer by showing the picture on computer.
You will be given a template containing only one kind of character and spaces, and the template shows how the endless picture is created----use the characters as basic elements and put them in the right position to form a bigger template, and then repeat and repeat doing that. Here is an example.

# #
 #      <-template
# #
So the Level 1 picture will be

# #
 #
# #
Level 2 picture will be

 

# #     # #
 #         #
# #     # #
     # #   
      #    
     # #   
# #    # #
 #        # 
# #    # #

输入:

The input contains multiple test cases.
The first 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 N lines describe the template.
The following line contains an integer Q, which is the Scale Level of the picture.
Input is ended with a case of N=0.
It is guaranteed that the size of one picture will not exceed 3000*3000.

输出:

For each test case, just print the Level Q picture by using the given template.

样例输入:
3
# #
 # 
# #
1
3
# #
 # 
# #
3
4
 OO 
O  O
O  O
 OO 
2
0
样例输出:
# #
 # 
# #
# #   # #         # #   # #
 #     #           #     # 
# #   # #         # #   # #
   # #               # #   
    #                 #    
   # #               # #   
# #   # #         # #   # #
 #     #           #     # 
# #   # #         # #   # #
         # #   # #         
          #     #          
         # #   # #         
            # #            
             #             
            # #            
         # #   # #         
          #     #          
         # #   # #         
# #   # #         # #   # #
 #     #           #     # 
# #   # #         # #   # #
   # #               # #   
    #                 #    
   # #               # #   
# #   # #         # #   # #
 #     #           #     # 
# #   # #         # #   # #
     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     
#include <iostream>
#include <iostream>
#include <cmath>
#include<math.h>
using namespace std;
const int N=3000;
char b[N+10][N+10];
int main()
{
    int n,q,dsize;//dsize边长
    char a[6][6];
    while(cin>>n&&n!=0)
    {
        cin.get();
        for(int i=0;i<n;i++)
            cin.getline(a[i],10);
        cin>>q;
        //开始计算
        dsize=pow(n+0.0,q);

        int t1,t2,m1,m2,tmp,j;/*遍历每一个点*/
        for(int x=0;x<dsize;x++)
        {
            for(int y=0;y<dsize;y++)
            {
                t1=x;
                t2=y;
                j=q;
                while(--j)
                {
                    tmp=pow(n+0.0,j);
                    m1=t1/pow(n+0.0,j);//除法是看该位置对应基本块的哪一个位置
                    m2=t2/pow(n+0.0,j);
                    if(a[m1][m2]== )//对应基本块的该位置为空格,则此处为空格
                    {
                        b[x][y]= ;
                        break;
                    }
                    t1=t1%tmp;//取余是将大图缩小成小图,最终缩小到基本快中
                    t2=t2%tmp;
                }
                if(!j){b[x][y]=a[t1][t2];}
            }
        }
        for(int x=0;x<dsize;x++)
        {
            for(int y=0;y<dsize;y++)
                cout<<b[x][y];
            cout<<endl;
        }
    }
    return 0;
}

 

题目1161:Repeater

标签:

原文地址:http://www.cnblogs.com/zhuoyuezai/p/5697012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!