2020-08-29 南蛮图腾

2020-08-29  本文已影响0人  JalorOo

https://www.luogu.com.cn/problem/P1498

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

long long qmi(int m, int k)
{
    int res = 1, t = m;
    while (k)
    {
        if (k&1) res = res * t;
        t = t * t;
        k >>= 1;
    }
    return res;
}

int read(){
    int x = 0,f = 1;
    char c = getchar();
    while (c<'0'||c>'9') {
        if (c=='-') {
            f = -1;
        }
        c = getchar();
    }
    while (c>='0'&&c<='9') {
        x = x*10+c-'0';
        c = getchar();
    }
    return x*f;
}
char a[1024][2048];//h,l

#define fi(a,b)  for(int i = a; i<b ;i++)
#define fj(a,b)  for(int j = a; j<b ;j++)

int main(){
    int n = read(),length=4,k=1;//length表示当前图腾的宽,length/2是图腾的高;
    fi(0,1024)
        fj(0,2048)
            a[i][j]=' ';//先全部置为空格(反正忽略行末空格2333)
    
    a[0][0]=a[1][1]='/';
    a[0][1]=a[0][2]='_';
    a[0][3]=a[1][2]='\\';//存n=1时的基础图腾(倒着的)
    
    while(k<n)//不断复制
    {
        fi(0,length/2)
            fj(0,length)
                a[i+(length/2)][j+(length/2)] = a[i][j+length] = a[i][j];
        length *= 2;
        k++;
    }
    
    for(int i=(length/2)-1;i>=0;i--)//倒序输出
    {
        fj(0,length)
            cout << a[i][j];
        cout << endl;
    }
    return 0;
}
/*
2
============
    /\
   /__\
  /\  /\
 /__\/__\
*/
上一篇下一篇

猜你喜欢

热点阅读