zoukankan      html  css  js  c++  java
  • HRBUST

     其他题可由本题变形得到.

    思路:利用坐标dfs搜索.

    注意:1,初始化.2,坐标实时更新(x,y)

    代码:

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #define ll long long
     5 using namespace std;
     6 const int amn=1e3+10;
     7 int a,b,con=0;
     8 char mp[amn][amn];
     9 char ans[amn][amn];
    10 void solve(int x,int y,int tot)
    11 {
    12     if(tot==a)
    13     {
    14         for(int k=x; k<tot+x; k++)
    15         {
    16             for(int l=y; l<tot+y; l++)
    17             {
    18                 if(mp[k-x][l-y]=='*')
    19                     ans[k][l]='*';
    20             }
    21         }
    22         return;
    23     }
    24     int tes=tot/a;
    25     for(int i=x; i<tot+x; i+=tes)
    26     {
    27         for(int j=y; j<tot+y; j+=tes)
    28         {
    29             if(mp[(i-x)/tes][(j-y)/tes]=='*')
    30             {
    31                 solve(i,j,tes);
    32             }
    33         }
    34     }
    35 }
    36 int main()
    37 {
    38     while(~scanf("%d%d",&a,&b))
    39     {
    40         for(int i=0; i<a; i++)
    41         {
    42             getchar();
    43             for(int j=0; j<a; j++)
    44                 scanf("%c",&mp[i][j]);
    45         }
    46         int c=1;///注意初始化
    47         for(int i=1; i<=b; i++)c*=a;
    48         for(int i=0; i<c; i++)
    49             for(int j=0; j<c; j++)
    50                 ans[i][j]=' ';
    51         solve(0,0,c);
    52         for(int i=0; i<c; i++)
    53         {
    54             for(int j=0; j<c; j++)
    55             {
    56                 printf("%c",ans[i][j]);
    57             }
    58             printf("
    ");
    59         }
    60         puts("");
    61     }
    62 }
  • 相关阅读:
    重定向管道
    系统安全
    Linux启动流程
    压缩解压
    Vim
    ssh
    sudo
    Raid
    rsync
    quota
  • 原文地址:https://www.cnblogs.com/Railgun000/p/10363596.html
Copyright © 2011-2022 走看看