九度 oj 题目1161:Repeater

来源:互联网 发布:大数据新闻报道 编辑:程序博客网 时间:2024/06/06 18:25

http://ac.jobdu.com/problem.php?pid=1161


#include <stdio.h>static int N,Q; static char Map[3001][3001];static char Template[6][6];int myPow(int n,int q){     int m = 1;    while(q--){     m*=n;         }     return m;} void make_map(int left,int up,int right,int down,int q,bool mark){     //printf("q:%d\n",q);     if(q == 1){         for (int i = up; i < down ; ++i) {             for (int j = left ; j < right ; j++) {                  Map[i][j]= mark? Template[i-up][j-left]:' ';             }              //printf("\n");         }          return ;    }       q--;    for (int i = 0; i < N; ++i) {         for (int j = 0; j < N; ++j) {                 make_map(left+j*myPow(N,q),up+i*myPow(N,q),left+(j+1)*myPow(N,q),up+(i+1)*myPow(N,q),q,mark&&Template[i][j]!=' ');         }      } } int main(){     //freopen("in/1161.in","r",stdin);     //freopen("out/1161.out","w",stdout);     while( scanf("%d",&N) && N!=0 ){        getchar();        for (int i = 0; i < N; ++i) {             for (int j = 0;  j< N; j++) {                 scanf("%c",&Template[i][j]);               }            getchar();         }          scanf("%d",&Q);         getchar();        //if(--ncase == 0) break;        make_map(0,0,myPow(N,Q),myPow(N,Q),Q,true);        for (int i = 0; i < myPow(N,Q); ++i) {             for (int j = 0;  j< myPow(N,Q); j++) {                 printf("%c",Map[i][j]);              }             printf("\n");         }     }  }  


0 0
原创粉丝点击